Namespace: custom

Properties
getId string

Returns the id of the given custom object.

getModel non-null gapi.drive.realtime.Model

Returns the model for the given custom object.

isCustomObject boolean

Returns true if obj is a custom collaborative object, otherwise false.

Methods
collaborativeField(name) unknown

Returns a reference that can be assigned to an object prototype field of a custom collaborative object in order to define custom collaborative properties. For example:

MyClass.prototype.name = gapi.drive.realtime.custom.collaborativeField('name');

The resulting field can be read and assigned to like a regular field, but the value will automatically be saved and sent to other collaborators.

registerType(type, name) void

Registers a user-defined type as a collaborative type. In order to create a collaborative object of this type, this must be called before {@code gapi.drive.realtime.load}. Otherwise, the custom object will be a {!gapi.drive.realtime.CollaborativeMap}.

setInitializer(type, initializerFn) void

Sets the initializer function for the given type. The type must have already been registered with a call to registerType.

setOnLoaded(type[, opt_onLoadedFn]) void

Sets the onLoaded function for the given type. The type must have already been registered with a call to registerType.

Properties

static
getId

Returns the id of the given custom object.

Parameter

Name Type Optional Description

obj

Object

 

A custom object.

Value must not be null.

Returns

string The object id.

static
getModel

Returns the model for the given custom object.

Parameter

Name Type Optional Description

obj

Object

 

A custom object.

Returns

non-null gapi.drive.realtime.Model The collaborative model for the given object.

static
isCustomObject

Returns true if obj is a custom collaborative object, otherwise false.

Parameter

Name Type Optional Description

obj

Object

 

A custom object.

Returns

boolean true if obj is a custom collaborative object, otherwise false.

Methods

static
collaborativeField(name) → unknown

Returns a reference that can be assigned to an object prototype field of a custom collaborative object in order to define custom collaborative properties. For example:

MyClass.prototype.name = gapi.drive.realtime.custom.collaborativeField('name');

The resulting field can be read and assigned to like a regular field, but the value will automatically be saved and sent to other collaborators.

Parameter

Name Type Optional Description

name

string

 

The stable field name.

Returns

unknown A dynamic property identifier.

static
registerType(type, name)

Registers a user-defined type as a collaborative type. In order to create a collaborative object of this type, this must be called before {@code gapi.drive.realtime.load}. Otherwise, the custom object will be a {!gapi.drive.realtime.CollaborativeMap}.

Parameters

Name Type Optional Description

type

function()

 

The type to register.

name

string

 

A name to use for this type.

static
setInitializer(type, initializerFn)

Sets the initializer function for the given type. The type must have already been registered with a call to registerType.

Parameters

Name Type Optional Description

type

function()

 

The type to register.

initializerFn

function(any type)

 

An initializer function that will be called in the context of the initialized object.

static
setOnLoaded(type[, opt_onLoadedFn])

Sets the onLoaded function for the given type. The type must have already been registered with a call to registerType.

Parameters

Name Type Optional Description

type

function()

 

The type to register.

opt_onLoadedFn

function()

Yes

An optional onLoaded function that will be called in the context of the newly-loaded object. If not specified, a default onLoaded handler will be used.

Send feedback about...

Realtime API
Realtime API