[TIMOB-16352] LiveView: App events are not cleared on reload
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 3.2.0, Release 3.2.1 |
Fix Version/s | n/a |
Components | LiveView |
Labels | liveview, supportTeam |
Reporter | Fokke Zandbergen |
Assignee | Unknown |
Created | 2014-01-27T07:30:33.000+0000 |
Updated | 2018-02-28T20:03:29.000+0000 |
Description
When a change triggers LiveView to reload the app, app events like
Ti.App.resumed
or Ti.Gesture.orientationchange
are not cleaned up and fire for once each time the app has been reloaded.
To reproduce
Run the following app with LiveView enabled and follow the steps on the screen:
var run = Ti.App.Properties.getInt('run', 0);
run++;
Ti.App.Properties.setInt('run', run);
function logEvent(e) {
console.log(e.type + ' #' + run);
}
Ti.App.addEventListener('resumed', logEvent);
Ti.Gesture.addEventListener('orientationchange', logEvent);
var win = Ti.UI.createWindow({
backgroundColor:'#fff'
});
win.add(Ti.UI.createLabel({
text: '1. Change something to trigger LiveView to restart the app.\n'
+ '2. Move app to background and then resume.\n'
+ '3. Change orientation.\n'
+ '4. Check logs.\n'
+ '5. Confirm that you see each event triggered twice.'
}));
win.open();
I tried the test case with LiveView enabled but for some reason I am not seeing any orientationchange or resumed event. It is a little strange as I see the same behavior with or without LiveView. I will try on another device tomorrow.
Well, that would be very strange indeed. I did the test on iOSSimulator, using the menu options to rotate and shake the device.
Moving this ticket to engineering as I can reproduce this issue with Appcelerator Studio 3.2.0 and LiveView.
I think it's even wider then App events, it's any non-UI event listeners, also on custom modules. So it might even mean these modules are never cleared as well?
Why backlog? IMHO this stops LiveView from being usable in any serious app using non-ui event listeners.
I'm having the same issue with Ti.App.fireEvent/addEventListener events and also with the facebook module's login/logout events.
I was hoping for a temporary workaround by detecting a reload from liveView but so far no succes. This issue makes liveView pretty useless
The issue is complex because apart from core-APIs firing global events, there could also be modules. The workaround is: * Use the
close
event on Windows * You can check if LiveView is active withif (localeStrings) ..
This seriously affects the ability to use LiveView on Android. Since the app is re-loaded effectively, can't all App.addEventListener and App.fireEvent's be reset?