Instantiating Connection
weihang7 opened this issue · comments
After including share.js,
var conn = sharejs.Connection();
throws
TypeError: Object #<Object> has no method 'reset'
Am I using it incorrectly to get the doc object, which the documentation says I should use Connection.get()
to get?
You need to give the connection object a socket to connect with. Eg:
var s = new BCSocket(null, {reconnect: true});
var sjs = new window.sharejs.Connection(s);
var doc = sjs.get('users', 'seph');
console.log(doc);
doc.subscribe();
doc.whenReady(function () {
if (!doc.type) doc.create('text');
if (doc.type && doc.type.name === 'text')
doc.attachTextarea(elem);
});