Skip to content

A Node.js library for sharing variables between 2 or more endpoints

License

Notifications You must be signed in to change notification settings

Anternet/shared-vars.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shared-vars.js

build npm Join the chat at https://gitter.im/Anternet/shared-vars.js npm

A Node.js library for sharing variables between 2 or more endpoints

This library is under development

Example

const shared = new SharedVars();
const localVar = shared.assign({foo: 1, bar: 'hi'});
shared.bind(12345);

const shared2 = new SharedVars();
shared2.ping({ address: '127.0.0.1', port: 12345 });

const remoteVar = shared2.get(localVar.id);

remoteVar.once('update', timestamp => {
  assert.deepEqual(remoteVar.value, localVar.value);
});

try {
  remoteVar.set('hello');
} catch (err) {
  assert.equal(err.message, 'This reference is readonly');
}

assert.equal(localVar.isWritable, true);
localVar.forward(shared2.address());

remoteVar.once('writable', () => {
  remoteVar.set('hello');
});

localVar.once('update', timestamp => {
  assert.equal(localVar.value, 'hello');
});

License

MIT License. Copyright © 2016 Moshe Simantov

About

A Node.js library for sharing variables between 2 or more endpoints

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published