javascript - Can I put a CollaborativeString inside a custom type? -


i'm reading google drive realtime api documentation on building collaborative data model.

i way gapi.drive.realtime.databinding.bindstring behaves. doesn't mess cursor placement when multiple people typing in same text box. requires pass collaborativestring.

but if register custom type, have use gapi.drive.realtime.custom.collaborativefield no matter type of field defining, , can't pass 1 of these bindstring. in fact, collaborativefield type not appear documented anywhere, , inspecting in console shows has no methods. means there's no registerreference method, collaborativestring uses keep track of cursor positions.

how frustrating. guess have work around it. see few options:

  1. ignore fact cursor gets messed during collaboration
  2. use collaborativemap instead of custom type, , wrap custom type @ runtime

probably going option 2.

i think misunderstand how site works, onus not on other people show how - you're asking other people take time day , you.

that being said, taking quick @ page linked shows want not possible quite straightforward , compatible bindstring. stealing example code page:

// call function before calling gapi.drive.realtime.load function registercustomtypes() {     var book = function () { };      function initializebook()     {         var model = gapi.drive.realtime.custom.getmodel(this);          this.reviews = model.createlist();         this.content = model.createstring();     }      gapi.drive.realtime.custom.registertype(book, 'book');      book.prototype.title = gapi.drive.realtime.custom.collaborativefield('title');     book.prototype.author = gapi.drive.realtime.custom.collaborativefield('author');     book.prototype.isbn = gapi.drive.realtime.custom.collaborativefield('isbn');     book.prototype.ischeckedout = gapi.drive.realtime.custom.collaborativefield('ischeckedout');     book.prototype.reviews = gapi.drive.realtime.custom.collaborativefield('reviews');     book.prototype.content = gapi.drive.realtime.custom.collaborativefield('content');      gapi.drive.realtime.custom.setinitializer(book, initializebook); } 

and

// pass 2nd param gapi.drive.realtime.load call function ondocloaded(doc) {     var docmodel = doc.getmodel();     var docroot = docmodel.getroot();      settimeout(function ()     {         var book = docmodel.create('book');          book.title = 'moby dick';         book.author = 'melville, herman';         book.isbn = '978-1470178192';         book.ischeckedout = false;          book.content.settext("call me ishmael. years ago - never mind how long precisely - having little or no money in purse, , nothing particular interest me on shore, thought sail little , see watery part of world.");          docroot.set('tbook', book);          debugger;     }, 0); } 

good luck , have fun realtime api - it's lot of fun play with.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -