Search code examples
design-patternsbackbone.jsevent-driven

Pattern to manage views in backbone


Coming from GWT, Backbone seems to miss a built-in solution on how to handle the life-cycle of a view. In GWT, every activity, which is more or less the equivalent to a View in Backbone, is managed by an ActivityManager which calls onStart/onStop on the activity, passing the eventBus and the element where the Activity can be rendered in. On stop, the ActivityManager will unbind all events the activity has bind to the eventbus and remove the view from the DOM.

In Backbone, it's easy to bind the events to model and collection but you have to remove them manually and there is no common api method where you will do this.

So I'm looking for best practice pattern on how to manage views to ensure no killed or disabled views are listening unnecessary to events.


Solution

  • Seems Marionette finally has the functionality I'm looking for.