Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1067] Ti.App.fireEvent behaves differently on iOS and Android

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionDuplicate
Resolution Date2014-03-26T04:26:55.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterIvo
AssigneeRitu Agrawal
Created2014-03-25T15:47:24.000+0000
Updated2016-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

Comments

  1. Ritu Agrawal 2014-03-25

    Thanks for reporting this issue. It is a duplicate of an existing ticket TIMOB-16246. Please follow along that ticket for further updates.

JSON Source