質問

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