How to integrate derby.js with express.js in node.js?

I use express for my Node application. I need to have some real time updates, such as facebook notifications. I need to integrate derby.js (which is building frames at the top of the express) only to trigger real-time notification in the express application. How can I complete this task?

Syntax

Expressjs I use

app.get('/', function(req, res){ //other things as fetch query res.render('index', { notificationcount : 0 }); }); 

The above thing will accept the number of notifications from the database and be displayed in the field of view.

Derbyjs sample syntax for real-time updates

 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(); }); }); 

I need only one section (field with counting notifications) from requests received from the displayed viewing page, from the derby. So the box will be updated in real time in the database.

How can we integrate derby view into express? Is it possible?

+4
source share
2 answers

Derby is a full-featured alpha infrastructure for building real-time applications. It sounds like you only need a small fraction of real time for specific functionality. I would recommend just using socket.io or sockjs - no need to integrate the whole structure for one tiny use case.

+2
source

Well, not sure where you bought the syntax, but

  • change {notificationcount} to {{notificationcount}} ...

and display the page correctly

 page.render('index', { notificationcount : 0 }); 

whenever your model changes, the site will change in real time. You should install and study examples: https://github.com/codeparty/derby-examples

0
source

All Articles