Google Drive SDK

Class gapi.drive.realtime.CollaborativeMap

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().

Namespacegapi.drive.realtimeClassgapi.drive.realtime.CollaborativeMap

Summary
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().

Functionclear Removes all entries.
Functiondelete Removes the entry for the given key (if such an entry exists).
Functionget Returns the value mapped to the given key.
Functionhas Checks if this map contains an entry for the given key.
FunctionisEmpty Returns whether this map is empty.
Functionitems Returns an array containing a copy of the items in this map. Modifications to the returned array do not modify this collaborative map.
Functionkeys Returns an array containing a copy of the keys in this map. Modifications to the returned array do not modify this collaborative map.
Functionset Put the value into the map with the given key, overwriting an existing value for that key.
Functionvalues Returns an array containing a copy of the values in this map. Modifications to the returned array do not modify this collaborative map.
FunctiongetId Returns the object ID.
FunctiontoString Returns a string representation of this collaborative object.
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.
Fieldsize The number of keys in the map.
Fieldid The ID of the collaborative object. Readonly.

Constructor

CollaborativeMap(model)

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().

Extends:
Classgapi.drive.realtime.CollaborativeObject
Parameters:
Classgapi.drive.realtime.Model modelThe document model.
See also:
Functiongapi.drive.realtime.Model.createMap

Functions

clear()

Removes all entries.

delete(key) -> *

Removes the entry for the given key (if such an entry exists).

Parameters:
string keyThe key to unmap.
Returns:
* The value that was mapped to this key, or null if there was no existing value.

get(key) -> *

Returns the value mapped to the given key.

Parameters:
string keyThe key to look up.
Returns:
* The value mapped to the given key.

has(key) -> boolean

Checks if this map contains an entry for the given key.

Parameters:
string keyThe key to check.
Returns:
boolean Returns true if this map contains a mapping for the given key.

isEmpty() -> boolean

Returns whether this map is empty.

Returns:
boolean Returns true if this map is empty.

items() -> Array.<Array>

Returns an array containing a copy of the items in this map. Modifications to the returned array do not modify this collaborative map.

Returns:
Array.<Array> The items in this map. Each item is a [key, value] pair.

keys() -> Array.<string>

Returns an array containing a copy of the keys in this map. Modifications to the returned array do not modify this collaborative map.

Returns:
Array.<string> The keys in this map.

set(key, value) -> *

Put the value into the map with the given key, overwriting an existing value for that key.

Parameters:
string keyThe map key.
* valueThe map value.
Returns:
* The old map value, if any, that used to be mapped to the given key.

values() -> Array.<Object>

Returns an array containing a copy of the values in this map. Modifications to the returned array do not modify this collaborative map.

Returns:
Array.<Object> The values in this map.

getId() -> string

Returns the object ID.

Returns:
string The id.

toString() -> string

Returns a string representation of this collaborative object.

Returns:
string A string representation.

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.

Fields

size -> number

The number of keys in the map.

id -> string

The ID of the collaborative object. Readonly.

Authentication required

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

Signing you in...

Google Developers needs your permission to do that.