Skip to content

Instantly share code, notes, and snippets.

@nornagon
Created May 28, 2011 00:35
Show Gist options
  • Save nornagon/996457 to your computer and use it in GitHub Desktop.
Save nornagon/996457 to your computer and use it in GitHub Desktop.
obj = sharejs.open('http://foo:3300/', 'doc_name', 'json')
obj.on('changed', function (ev) {...})
obj.at().set({}) // initial document
foo = obj.at('foo')
foo.set([0]) // { p: ['foo'], oi: [0] }
foo.push(3) // { p: ['foo', 1], li: 3 }
foo.insert(0, ['bar']) // { p: ['foo', 0], li: ['bar'] }
foo.get() // => [['bar'],0,3]
foo.at(0).push('baz') // { p: ['foo',0,1], li: 'baz' }
obj.get() // => { 'foo': [['bar','baz'],0,3] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment