Reputation: 21810
I'm building a dashboard application with Backbone.js
There is a grid of panes called modules. Each module has its own custom data that it needs to listen to.
each module has both shared responsibilities and separate responsibilities, as in, they all have titles, descriptions, etc, and yet they each have individual datasets.
how should I structure the application to achieve the constant flow of data to these separate modules?
Upvotes: 2
Views: 2372
Reputation: 4301
I strongly recommend you using backbone.marionette
here is a good starting point that will help you
i have developed complex dashboard applications using marionette, and the amount of time and effort i saved, was tremendous. naturally marionette incorporate several pub/sub mechanisms that easy your job.
Upvotes: 2
Reputation: 5410
When dealing with so many dependencies I would suggest a global pubSub class via
var pubsub = _.extend({}, Backbone.Events);
This way you can share events through
pubsub.on('some:channel', function () {
console.log('channel ', arguments);
});
pubsub.trigger('some:channel', 'Dude...');
with multiple modules and structure their response to it.
Upvotes: 4