Reputation: 9616
I am using express framework for my Node App. I need to have some real time updates like notifications in facebook. What I need is integrate derby.js(which is framework build on the top of express) only for real time notification triggering in express App. How can I accomplish this task?
Expressjs syntax I am using
app.get('/', function(req, res){
//other things as fetch query
res.render('index', { notificationcount : 0 });
});
Above thing will take notification count from database and displayed in view.
Derbyjs sample syntax for real time update
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();
});
});
What I need is only one section(box with notification count) from express rendered view page needs come from derby. So that the box will updated on real time updates on Database.
How we can integrate derby view in express? Is it possible?
Upvotes: 4
Views: 879
Reputation: 4618
Well, not sure where you bought the syntax, but
and render the page correctly
page.render('index', { notificationcount : 0 });
whenever your model changes, site will change live. You should install and study the examples :: https://github.com/codeparty/derby-examples
Upvotes: 0
Reputation: 25188
Derby is a full-featured alpha framework for building real-time apps. It seems like you only need a small amount of real-time for specific functionality. I'd recommend just using socket.io or sockjs - no need to integrate an entire framework for one tiny use case.
Upvotes: 2