Skip to content

Instantly share code, notes, and snippets.

@kwhinnery
Last active February 9, 2016 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwhinnery/337910ac32b6f1f24cde to your computer and use it in GitHub Desktop.
Save kwhinnery/337910ac32b6f1f24cde to your computer and use it in GitHub Desktop.
var client = twilio.sync('jwt token here');
// Example Document interaction
var doc = client.Document('uniqueName');
doc.set({
foo: 'bar'
});
doc.on('update', function(e) {
console.log('doc was updated');
});
// Example Map interaction
var map = client.Map('uniqueMapName');
map.set('foo', { bar: true });
console.log(map.get('foo').bar);
map.on('itemAdded', function(key, value) {
console.log('We now have ' + key + ' set to: ' + value);
});
map.on('itemUpdated', function(key, newValue, oldValue) {
console.log('Now ' + key + ' is set to: ' + newValue);
console.log('It used to be: ' + oldValue);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment