【发布时间】:2013-04-13 17:00:05
【问题描述】:
我正在为我的 Node 应用程序使用 express 框架。我需要一些实时更新,例如 facebook 中的通知。我需要的是集成derby.js(这是构建在express之上的框架)仅用于express App中的实时通知触发。我怎样才能完成这项任务?
Expressjs 我正在使用的语法
app.get('/', function(req, res){
//other things as fetch query
res.render('index', { notificationcount : 0 });
});
以上内容将从数据库中获取通知计数并显示在视图中。
Derbyjs 实时更新示例语法
app.view.make('Body'
, 'Notications: <div>{notificationcount}</div>'
);
app.get('/', function (page, model) {
// Subscribe specifies the data to sync
model.subscribe('notificationcount', function () {
page.render();
});
});
我需要的只是来自 derby 的快速渲染视图页面需求中的一个部分(带有通知计数的框)。这样该框将根据数据库的实时更新进行更新。
我们如何在 express 中集成 derby 视图?是否可以?
【问题讨论】:
标签: javascript node.js express real-time-updates derbyjs