Lets Talk; An EventBus in Backbone.js
spin.atomicobject.com
Lets Talk; An EventBus in Backbone.js
1–10 of 12 posts
Re: Lets Talk; An EventBus in Backbone.js
#2It's also easier to debug if all your events business happens in one place.
Re: Lets Talk; An EventBus in Backbone.js
#3Re: Lets Talk; An EventBus in Backbone.js
#4A central event emitter is common practice in client software. It is also known as the event aggregator pattern. A nice description by Martin Fowler[1] [1] http://martinfowler.com/eaaDev/EventAggregator.html
http://devlicio.us/blogs/mike_nichols/archive/2011/08/14/bac...
Re: Lets Talk; An EventBus in Backbone.js
#5Some pitfalls:
- easy to create zombie objects
- easy to break sub-view re-usability
- gl hf if you have managed to end up with x-references
Re: Lets Talk; An EventBus in Backbone.js
#6Re: Lets Talk; An EventBus in Backbone.js
#7http://stackoverflow.com/questions/9405148/how-can-i-bubble-...
...I always just do something along the lines of window.MyAppNamespace.EventProxy = _.extend({}, Backbone.Events);
The nice thing about this tactic is that it loosely couples interactions between your views. A coworker who also uses Backbone.js prefers passing references between your views to each other. Although this makes the code easier to read in some cases, since it's more obvious what the flow of control is, it tightly couples the components.
Re: Lets Talk; An EventBus in Backbone.js
#8Re: Lets Talk; An EventBus in Backbone.js
#9Re: Lets Talk; An EventBus in Backbone.js
#10The Backbone documentation actually mentions this too (last sentence of the introductory paragraph here: http://documentcloud.github.com/backbone/#Events ).