[AC-1067] Ti.App.fireEvent behaves differently on iOS and Android
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2014-03-26T04:26:55.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | Ivo |
Assignee | Ritu Agrawal |
Created | 2014-03-25T15:47:24.000+0000 |
Updated | 2016-03-08T07:37:24.000+0000 |
Description
When custom event is fired on iOS it is executed with some delay (waits until the executing context has finished).
On the contrary, when custom event is fired on Android the event handler executes immediately without waiting for the current executing context to finish.
Issue can be seen with the following sample:
var win = Titanium.UI.createWindow({
backgroundColor:'red'
});
var btn = Ti.UI.createButton({
width : 100,
height : 100,
title : "Click Me"
});
btn.addEventListener("click", function() {
for (var i = 1; i < 6; i++) {
Ti.API.info(i);
}
// event is only fired here. should not be executed immidiately
Ti.App.fireEvent("myEvent", {prop1 : "prop1"});
for (var i = 6; i < 11; i++) {
Ti.API.info(i);
}
});
Ti.App.addEventListener("myEvent", function(args) {
Ti.API.info("Executing the event handler now...");
});
win.add(btn);
win.open();
which produces the following output:
[INFO] : 1
[INFO] : 2
[INFO] : 3
[INFO] : 4
[INFO] : 5
[INFO] : 6
[INFO] : 7
[INFO] : 8
[INFO] : 9
[INFO] : 10
[INFO] : Executing the event handler now...
[INFO] : 1
[INFO] : 2
[INFO] : 3
[INFO] : 4
[INFO] : 5
[INFO] : Executing the event handler now...
[INFO] : 6
[INFO] : 7
[INFO] : 8
[INFO] : 9
[INFO] : 10
Thanks for reporting this issue. It is a duplicate of an existing ticket TIMOB-16246. Please follow along that ticket for further updates.