You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bob Holt edited this page May 14, 2013
·
3 revisions
The MessageBus is a singleton object that inherits from Backbone.Events. This gives us some degree of control over which methods we allow to be used on the MessageBus - which pretty much comes down to just trigger(). All other methods are either marked as deprecated or will throw errors.
The reason for this is that listening should be done by the views like so:
listenTo() and stopListening should be used on the View. on(), off(), and once(), while available to the View, should not be used at all, due to the improved event binding management in Backbone 1.0 (once() uses on() behind the scenes).
This leaves trigger(), which is used like so to fire the event the View above is listening for:
MessageBus.on() and MessageBus.off() do not automatically throw errors in Keel, as these are required for the event handling behind the scenes (the listenTo example above invokes MessageBus.on() in order to actually bind the event).