我尝试按照构建协作数据模型中描述的步骤进行操作,最终得到以下代码:
function onLoad(doc){
var Book = function(){};
var model = doc.getModel();
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');
var book = model.create('Book');
model.getRoot().set('book', book);
book.addEventListener(gapi.drive.realtime.EventType.OBJECT_CHANGED, function(e){console.log(e);});
book.title = 'Moby Dick';
book.author = 'Melville, Herman';
book.isbn = '978-1470178192';
book.isCheckedOut = false;
}
不幸的是,执行此操作时,执行时出现以下错误var book = model.create('Book');
:
未捕获的 java.lang.IllegalArgumentException:未知类型名称 Book
Drive Realtime API 错误:invalid_compound_operation:在同步块结束时打开复合操作 - 您是否忘记调用 endCompoundOperation()?
我想念什么?