Problem description
Whenever a require function is called, the network change event listener is broken.
Steps to reproduce
Create 3 files: app.js, win.js and view.js
*app.js*
(function() {
var Window = require('win');
new Window().open();
})();
*win.js*
function ApplicationWindow() {
var view = require('view'); // just requiring, we are not even invoking the function
var self = Ti.UI.createWindow({
backgroundColor:'#ffffff',
navBarHidden:true,
exitOnClose:true
});
return self;
}
module.exports = ApplicationWindow;
*view.js*
function SimpleView() {
var view = Ti.UI.createView({
backgroundColor:'red',
width: 100,
height: 100
});
return view;
}
module.exports = SimpleView;
Now, there are 3 scenarios; use this simple listener code:
Titanium.Network.addEventListener('change', function(e) {
alert('Status changed:' + e.networkType);
});
1. add the network listener code in app.js or win.js: it will only be fired ONCE [BUG]
2. add the listener code in view.js: everything is ok
3. add the listener code in win.js and remove the require('view') from it: everything is ok
- I've tested back with 2.1.2, 2.1.1 and 2.1.0: same results. - I've tested with 2.0.2: the listener is not called even once. - However, testing with v3.0.0.20121026170116 seems to be working. Was this addressed in the release? Below a simpler test case: app.js
win.js
Tested with latest master and 3_0_X. The two test cases both pass. Mark the ticket as Cannot Reproduce.
Closing ticket as I am unable to reproduce this issue with the following environment; Pixel (7.1) MacOS 10.11.6 (15G31) Studio 4.8.1.201612050850 Ti SDK 6.0.3 GA Appc NPM 4.2.8 Appc CLI 6.1.0 Ti CLI 5.0.11 Alloy 1.9.5 Arrow 1.10.1 Xcode 8.2 (8C38) Node v4.6.0 Java 1.7.0_80