Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1290] Provide a global event dispatcher as alternative for Ti.App.fireEvent

GitHub Issuen/a
TypeNew Feature
PriorityNone
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsRuntime
Labelsevents
ReporterFokke Zandbergen
AssigneeBruce Wayne
Created2015-07-08T18:56:15.000+0000
Updated2015-07-08T18:56:15.000+0000

Description

I once wrote an article on tiDev titled _The case against Ti.App.fireEvent_: http://www.tidev.io/2014/09/10/the-case-against-ti-app-fireevent-2/ In short: using Ti.App.fireEvent is bad because your listening to these events in JavaScript elsewhere so there's no need to cross the bridge, in particular with big payloads. The alternative in Alloy is to simply use Backbone.Events to create a JS-only dispatcher. This as easy has:
Alloy.Events = _.extend({}, Backbone.Events);

Alloy.Events.on('myEvent', fn);
Alloy.Events.trigger('myEvent');
Since it is this easy.. why not add this to the Alloy library as another global object next to Alloy.CFG and Alloy.Globals.

Comments

No comments

JSON Source