I have complex backbone application with many nested views ( marionette layouts and regions ) and I already use marionette eventmanager to coordinate between these views. But half way through the coding I realize that I am in the process of creating too many events and to complicate even further I have few events triggering more than one actions.
How are events being managed by other complex backbone apps out there.. Any guidelines , best practices, etc., to keep in mind when dealing with events before I dig myself into a bigger hole.
Thanks
I’m not sure which events framework you’re using, so without any assumptions, make sure that you’re using Marionette’s EventBinder that is available directly in all Marionette views, and optionally the EventAggregator for app-level events that cross too many boundaries and for decoupling modules.
I’m not an expert on the subject, so the following is not authoritative in any way:
EventBinderas follows:In the parent view:
In the subview:
For cross-module or cross-view event propagation, basically app-wide events, use the application’s
EventAggregator:For reusable modules that shouldn’t depend on a specific application object, you can use a custom
EventBinderorEventAggregator.For a longer discussion, see: