Google Drive SDK

Realtime API Reference

gapi.drive.realtime

The Google Realtime API.

Namespacecustom A namespace that includes methods for registering and working with custom collaborative objects.
Namespacedatabinding A namespace that includes classes and methods for binding collaborative objects to UI elements.
ClassBaseModelEvent A base class for model events.
ClassCollaborativeList A collaborative list. A list can contain other Realtime collaborative objects, custom collaborative objects, JavaScript primitive values, or JavaScript objects that can be serialized to JSON.

Changes to the list will automatically be synced with the server and other collaborators. To listen for changes, add EventListeners for the following event types:

  • gapi.drive.realtime.EventType.VALUES_ADDED
  • gapi.drive.realtime.EventType.VALUES_REMOVED
  • gapi.drive.realtime.EventType.VALUES_SET

This class should not be instantiated directly. To create a new list, use gapi.drive.realtime.Model.prototype.createList().

ClassCollaborativeMap A collaborative map. A map's key must be a string. The values can contain other Realtime collaborative objects, custom collaborative objects, JavaScript primitive values or JavaScript objects that can be serialized to JSON.

Changes to the map will automatically be synced with the server and other collaborators. To listen for changes, add EventListeners for the gapi.drive.realtime.EventType.VALUE_CHANGED event type.

This class should not be instantiated directly. To create a new map, use gapi.drive.realtime.Model.prototype.createMap().

ClassCollaborativeObject CollaborativeObject contains behavior common to all built in collaborative types. This class should not be instantiated directly. Use the create* methods on gapi.drive.realtime.Model to create specific types of collaborative objects.
ClassCollaborativeString Creates a new collaborative string. Unlike regular JavaScript strings, collaborative strings are mutable.

Changes to the string will automatically be synced with the server and other collaborators. To listen for changes, add EventListeners for the following event types:

  • gapi.drive.realtime.EventType.TEXT_INSERTED
  • gapi.drive.realtime.EventType.TEXT_DELETED
This class should not be instantiated directly. To create a new collaborative string, use gapi.drive.realtime.Model.prototype.createString
ClassCollaborator A collaborator on the document.
ClassCollaboratorJoinedEvent An event indicating that a new collaborator has joined the document.
ClassCollaboratorLeftEvent An event indicating that a collaborator left the document.
ClassDocument A Realtime document. A document consists of a Realtime model and a set of collaborators. Listen on the document for the following events:
  • gapi.drive.realtime.EventType.COLLABORATOR_LEFT
  • gapi.drive.realtime.EventType.COLLABORATOR_JOINED
  • gapi.drive.realtime.EventType.DOCUMENT_SAVE_STATE_CHANGED

This class should not be instantiated directly. The document object is generated during the document load process.
ClassDocumentClosedError An error that is thrown when attempting to access a closed document (or any model or collaborative object associated with a closed document).
ClassDocumentSaveStateChangedEvent An event that indicates that the save state of a document has changed. If both isSaving and isPending are false, the document is completely saved and up to date.
ClassError An error affecting the realtime document.
ClassEventTarget An event target which can dispatch events to interested listeners. Listeners subscribe via addEventListener.
ClassIndexReference An IndexReference is a pointer to a specific location in a collaborative list or string. This pointer automatically shifts as new elements are added to and removed from the object.

To listen for changes to the referenced index, add an EventListener for gapi.drive.realtime.EventType.REFERENCE_SHIFTED.

This class should not be instantiated directly. To create an index reference, call registerReference on the appropriate string or list.

ClassModel The collaborative model is the data model for a Realtime document. The document's object graph should be added to the model under the root object. All objects that are part of the model must be accessible from this root.

The model class is also used to create instances of built in and custom collaborative objects via the appropriate create method.

Listen on the model for the following events:

  • gapi.drive.realtime.EventType.UNDO_REDO_STATE_CHANGED
This class should not be instantiated directly. The collaborative model is generated during the document load process. The model can be initialized by passing an initializer function to gapi.drive.realtime.load.
ClassObjectChangedEvent Event fired when a collaborative object changes. This event will bubble to all of the ancestors of the changed object. It includes an array of events describing the specific changes.
ClassReferenceShiftedEvent Event fired when an index reference shifts
ClassTextDeletedEvent Event fired when text is removed from a string.
ClassTextInsertedEvent Event fired when text is inserted into a string.
ClassUndoRedoStateChangedEvent An event indicating that canUndo or canRedo changed.
ClassValueChangedEvent Event fired when a map or custom object property changes.
ClassValuesAddedEvent Event fired when items are added to a collaborative list.
ClassValuesRemovedEvent Event fired when items are removed from a collaborative list.
ClassValuesSetEvent Event fired when items in a collaborative list are changed in place.
FunctiongetToken Returns an OAuth access token.
Functionload Loads the Realtime document associated with fileId. If no Realtime document is associated with fileId, a new Realtime document associated with fileId will be created.
FunctionloadAppDataDocument Loads a Realtime document that is appropriate for storing data that is application and user specific, such as preferences. For a given authenticated user and application, this document is guaranteed to be a singleton. If no such a document exists, it will be created in the authenticated application's hidden "Application Data" folder (if the "Application Data" folder does not exist it will be created as well). To use this function, the OAuth token must have the drive.appdata scope. See https://developers.google.com/drive/appdata for more details on the Application Data folder.
EnumErrorType Errors that can occur while loading or collaborating on a document.
EnumEventType Events fired by the document or collaborative objects.

gapi.drive.realtime.custom

A namespace that includes methods for registering and working with custom collaborative objects.

FunctioncollaborativeField 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.
FunctiongetId Returns the ID of the given custom object.
FunctiongetModel Returns the model for the given custom object.
FunctionisCustomObject Returns true if obj is a custom collaborative object, otherwise false.
FunctionregisterType Registers a user-defined type as a collaborative type. This must be called before {@code gapi.drive.realtime.load}.
FunctionsetInitializer Sets the initializer function for the given type. The type must have already been registered with a call to registerType.
FunctionsetOnLoaded Sets the onLoaded function for the given type. The type must have already been registered with a call to registerType.

gapi.drive.realtime.databinding

A namespace that includes classes and methods for binding collaborative objects to UI elements.

ClassAlreadyBoundError An error that is thrown when attempting to bind a DOM element which has already been bound to a collaborative value.
ClassBinding A binding between a collaborative object in the data model and a DOM element.
FunctionbindString Binds a text input element to an collaborative string. Once bound, any change to the collaborative string (including changes from other remote collaborators) is immediately displayed in the text editing control. Conversely, any change in the text editing control is reflected in the data model.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.