Google Drive SDK

Class gapi.drive.realtime.Document

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.

Namespacegapi.drive.realtimeClassgapi.drive.realtime.Document

Summary
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.
Functionclose Closes the document and disconnects from the server. After this function is called, event listeners will no longer fire and attempts to access the document, model, or model objects will throw a {@link gapi.drive.realtime.DocumentClosedError}. Calling this function after the document has been closed will have no effect.
FunctiongetCollaborators Gets an array of collaborators active in this session. Each collaborator is a jsMap with these fields: sessionId, userId, displayName, color, isMe, isAnonymous.
FunctiongetModel Gets the collaborative model associated with this document.
FunctionaddEventListener Adds an event listener to the event target. The same handler can only be added once per the type. Even if you add the same handler multiple times using the same type then it will only be called once when the event is dispatched.
FunctionremoveEventListener Removes an event listener from the event target. The handler must be the same object as the one added. If the handler has not been added then nothing is done.

Constructor

Document(bridge, commService, errorHandlerFn)

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.

Extends:
Classgapi.drive.realtime.EventTarget
Parameters:
gapi.drive.realtime.GwtDocumentBridge bridgeThe driver for the GWT collaborative libraries.
Object commServiceThe communication service to dispose when this document is disposed.
function(!Classgapi.drive.realtime.Error) errorHandlerFnThe third-party error handling function.
See also:
Functiongapi.drive.realtime.load

Functions

close()

Closes the document and disconnects from the server. After this function is called, event listeners will no longer fire and attempts to access the document, model, or model objects will throw a {@link gapi.drive.realtime.DocumentClosedError}. Calling this function after the document has been closed will have no effect.

getCollaborators() -> Array.<Classgapi.drive.realtime.Collaborator>

Gets an array of collaborators active in this session. Each collaborator is a jsMap with these fields: sessionId, userId, displayName, color, isMe, isAnonymous.

Returns:
Array.<Classgapi.drive.realtime.Collaborator> A jsArray of collaborators.

getModel() -> Classgapi.drive.realtime.Model

Gets the collaborative model associated with this document.

Returns:
Classgapi.drive.realtime.Model The collaborative model for this document.

addEventListener(type, handler, opt_capture)

Adds an event listener to the event target. The same handler can only be added once per the type. Even if you add the same handler multiple times using the same type then it will only be called once when the event is dispatched.

Parameters:
string typeThe type of the event to listen for.
Function|Object handlerThe function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
boolean= opt_captureIn DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.

removeEventListener(type, handler, opt_capture)

Removes an event listener from the event target. The handler must be the same object as the one added. If the handler has not been added then nothing is done.

Parameters:
string typeThe type of the event to listen for.
Function|Object handlerThe function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
boolean= opt_captureIn DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.

Authentication required

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

Signing you in...

Google Developers needs your permission to do that.