A mapping of the events this model could emit to each event's unique name. Use this to refer an event name:
rtModel.on(RealTimeModel.Events.COLLABORATOR_OPENED, function listener(e) {
// ...
})
Adds a new event listener for the specified event. The class will ignore duplicate registrations of the same listener to the same event.
The name of the event to add the listener for.
The listener callback to register.
This object, in support of a fluent API.
Returns the number of model changes that have accumulated since startBatch was called.
Cancels the batch job. Note that calling this once changes have occurred
on this model since the batch was started (that is, batchSize() > 0
) will
result in an error.
Closes the model, emitting the appropriate events to any other participants and cleaning up any opened resources.
Returns an array of collaborators, or other users who currently have this model open.
an array of collaborators
Returns an observable which emits whenever a collaborator opens or closes this model. This is useful for keeping an up-to-date listing of current collaborators.
Also see the PresenceService for a more robust mechanism for keeping tabs on who is available for participation within the domain.
The collection ID to which this model belongs.
Sends any accumulated model changes to the server as one atomic operation. This also removes the batch flag such that subsequent individual changes are immediately processed and sent as normal.
The timestamp at which this model was first created.
Given a search path, returns the RealTimeElement at that path, or null if no such element exists.
the search path for accessing a node within this model's data
Given an array of search path elements, returns the RealTimeElement at that path, or null if no such element exists.
an array of search path elements (which in totality are a Path)
Creates an Element Reference, which is a Reference bound to one more elements in this model's data.
a unique name for this ElementReference
An empty LocalElementReference
which can then be bound to one or more elements.
Returns true if local changes to this model are being emitted.
FIXME inconsistent with isOpen()
Toggles the emitLocalEvents
setting. If set to true
, whenever any data
within this model is mutated, the same events will be emitted as if the mutation
happened remotely. This is useful for handling change events in one place,
switching on the IConvergenceModelValueEvent.local field.
true if local changes to this model should emit
Provides the events emitted by this object as an Observable stream.
An Observable stream of all events emitted by this object.
Returns true if this model is currently in batch mode, that is, startBatch
was called and the batch was not completed or cancelled.
True if a batch is in progress, false otherwise.
Informs clients if the model is closing.
True if the model is closing.
Determines if all local changes (if any) have been committed by the server.
true if the model has no unacknowledged changes, false otherwise.
Determines is this model is a model that was created offline, and has not been synced to the server yet.
True if the model was created locally and has not synced to the server, false otherwise.
Returns true if this model is currently open.
Determines if this model is marked to be made available offline.
True if the model is marked for offline availability, false otherwise.
Alias of time
Alias for version
Alias of createdTime
The first version of the model (0
).
This model's ID, unique in the Domain.
Removes a single event listener for a specific event.
The name of the event to remove the listener for.
The listener callback to unregister.
This object, in support of a fluent API.
Adds a new event listener for the specified event. The class will ignore duplicate registrations of the same listener to the same event.
The name of the event to add the listener for.
The listener callback to register.
This object, in support of a fluent API.
Adds a single shot event listener for the specified event. The listener will be called the first time the specified event is fired after the event registration occurs, after which the registration will be removed and no further events will be passed to the listener.
The name of the event to add the listener for.
The listener callback to register.
This object, in support of a fluent API.
Returns the permissions the current user has on this model.
Returns a permission manager that can be used to manage global or per-user
permissions on this model. Requires the manage
permission.
Returns the remote ModelReference created by the given sessionId
with
the unique name key
, or undefined
if no such reference exists.
See Remote References in the developer guide.
The session ID that created the reference
the reference's unique key
A model reference for thee specified sessionId and key.
Returns any remote references that match the given filter. You can provide
a single key
which could return references from multiple users, sessionId
which would return all of a particular user session's references, or both,
which is really just the same as using the reference method.
an object containing either a sessionId
, key
, or both
An array of remote ModelReferences, or an empty array if there were no matches.
Removes all listeners for all events. This is useful for cleanup before disposing of this particular event emitter.
This object, in support of a fluent API.
Removes a single event listener for a specific event.
The name of the event to remove the listener for.
The listener callback to unregister.
This object, in support of a fluent API.
Removes all listeners bound on the given event.
the name of the event to remove listeners for
This object, in support of a fluent API.
Returns an array of collaborators, or other users who currently have this model open.
an array of collaborators
Returns a RealTimeObject wrapping the root node of this model's data. From here one can view or modify all or any part of the subtree at any level of granularity.
The session associated with this opened model.
Sets a flag on this model to indicate that any subsequent changes will be batched into one atomic operation. See Batch Changes in the developer guide.
Note that a single batch operation must be fully encompassed in a single JS event loop ("tick"). This is to guarantee that no incoming events can conflict with the batch job.
Marks this model to be available offline.
The timestamp at which this model was last modified.
Marks this model no longer needs to be available offline.
The current version of the model.
A promise the will be resolved when the model is closed. If the model is already closed, the promise will be immediately resolved.
This is the core construct for dealing with distributed data in Convergence. It is essentially a distributed data model: Anybody in the same domain with permissions to this model can open it at the same time, be notified of remote changes, and modify the data within, which is itself synchronized in the same way between all participants. Any co-modification conflicts are resolved automatically and consistently for all connected users so that everybody sees the same thing.
See this page in the developer guide for a few of the interesting things you can do with a RealTimeModel.
Any data that can be represented with JSON can be stored in a RealTimeModel. This allows a huge range of applications to sync data instantly and seamlessly with Convergence.
To work with the data within (reading and writing):
See RealTimeModelEvents for the events that may be emitted on this model.