Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

objsync

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

objsync

Object synchronization between clients via Socket.io-socket-like transports.

  • 0.1.0-6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

ObjSync

Object synchronization between clients via Socket.IO socket-like transports.

Public API

  • (constructor)(< Socket.IO socket-like >transport, [< object >options])
    Creates and returns a new ObjSync object, which communicates via transport.
    Valid options:
    • delimiter - string - The string to use as delimiter between keys. Default: '.'
    • subscribe - bool - Whether the syncer should subscribe to incomming updates. If set to false, no incomming updates will be accepted. Default: 'true'
    • publish - bool - Sets whether the syncer should publish updates. If set to false, no updates will be sent. Default: 'false' Note: Two-way syncing can only be done if both sides have equal objects at the time that the connection is made!

Inherits all methods of KVCObject. All updates are automatically (and minimally) synced.

Examples

Client A. Will send updates.

var io = require('socket.io-client');
var ObjSync = require('objsync');

var transport = io.connect('localhost', {port:8888});
var sync = new ObjSync(transport, {subscribe:false, publish:true});

sync.setObject({foo:'bar', person:{name:'johnny'}});

Client B, aka server-side. Will receive updates.

var io = require('socket.io');
var ObjSync = require('objsync');

var transport = io.listen(8888).sockets;
var sync = new ObjSync(transport);

sync.once('update', function (updated) {
    console.dir(updated); // will print { foo: 'bar', 'person.name': 'johnny' }
    console.dir(sync.getObject()); // will print { foo: 'bar', person: { name: 'johnny' } }
});

Keywords

FAQs

Package last updated on 05 Sep 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc