DailyJS

A Server for Realtime Apps: deepstream.io

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

apps realtime servers node

A Server for Realtime Apps: deepstream.io

Posted by Alex R. Young on .
Featured

apps realtime servers node

A Server for Realtime Apps: deepstream.io

Posted by Alex R. Young on .

deepstream.io

Wolfram Hempel sent in an open source server called deepstream.io (GitHub: hoxton-one/deepstream.io, License: MIT, npm: deepstream.io). Deepstream is a Node server that allows clients to sync data, whether they're browsers or mobile applications. It has a caching layer, and supports event-based messaging and RPC.

If you install deepstream.io with npm, you can create a simple server like this:

var DeepstreamServer = require( 'deepstream.io' );  
var server = new DeepstreamServer();

server.set('host', 'localhost');  
server.set('port', 6020);

server.start();  

Then in the browser you can connect with var ds = deepstream('localhost:6020').login(). The ds object can be used to fetch and set data. The tutorial shows how to do this with a simple HTML form:

var record = ds.record.getRecord('someUser');  
var input = document.querySelector('input');

input.onkeyup = function() {  
  record.set('firstname', input.value ;
};

record.subscribe('firstname', function(value) {  
  input.value = value;
});

The RPC calls allow functions to be bound to function names. One nice property of RPC in deepstream is if multiple clients are able to provide the same RPC, it will distribute requests evently between them.

The project is still new, but there are a good amount of tutorials already, including React and Angular examples.