Uploaded image for project: 'Alloy'
  1. Alloy
  2. ALOY-1290

Provide a global event dispatcher as alternative for Ti.App.fireEvent

    Details

    • Type: New Feature
    • Status: Open
    • Priority: None
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Runtime
    • Labels:

      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.

        Attachments

          Activity

            People

            • Assignee:
              batman Bruce Wayne
              Reporter:
              fokkezb Fokke Zandbergen
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Integration