문제

Assume the custom book object described in the developer guide

myApp.Book = function() {}
gapi.drive.realtime.custom.registerType(myApp.Book, 'Book');
myApp.Book.prototype.title = gapi.drive.realtime.custom.collaborativeField('title');
// ... other fields
var book = model.create('Book');
model.getRoot().set('book', book);

Is there any way for another client to know that the object at model.getRoot().get('book') is a 'Book'?

The API will tell you whether or not it is a custom object (gapi.drive.realtime.custom.isCustomObject(model.getRoot().get('book')) == true), but not what the type of the custom object is

도움이 되었습니까?

해결책

Generally the client should be able to assume the type based on the data model structure.

If your data model structure is ambiguous, you could add a "name" property to each of your custom objects to distinguish.

Just set a value in the initializer. (See https://developers.google.com/drive/realtime/build-model#registering_and_creating_custom_objects)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top