简体   繁体   English

仪表板的ribs.js设计模式

[英]backbone.js design pattern for a dashboard

I'm building a dashboard application with Backbone.js 我正在使用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 当处理这么多依赖项时,我建议通过以下方式创建全局pubSub类:

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 我强烈建议您使用bone.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. 木偶很自然地融合了多种发布/订阅机制,可简化您的工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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