Acquiring subscriptions

In order to acquire the subscriptions in the browser clients and handle the updates, Snorky.js provides a DataSync connector.

Basic usage

The DataSync service usage is very simple, just tell Snorky() that you need a Snorky.DataSync() service.

var snorky = new Snorky(WebSocket, "ws://localhost:8001/ws", {
  "datasync": Snorky.DataSync
class Snorky.DataSync()

DataSync service connector.



Event raised when a delta arrives.

The event is dispatched with the delta as argument, being it a dictionary with the following fields:


The model class over the change occurred.


The type of the delta. Will be either "insert", "update" or "delete".


The element added or removed. Only in insert and delete deltas.


The element before the update. Only in update deltas.


The element after the update. Only in update deltas.

You can bind the deltaReceived event and process the deltas as required by your application.
  function (delta) {
    if (delta.type == "insert") {
      /* code for insertions */
    } else if (delta.type == "update") {
      /* code for updates */
    } else if (delta.type == "delete") {
      /* code for deletions */