简体   繁体   中英

backbone.js design pattern for a dashboard

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM