Events
The collaboration client has a set of events you can subscribe to. This helps you keep your app's UI in sync with any backend changes that happen.
There are two different ways to subscribe to events - global events and entity specific events
#
Global eventsGlobal events are events that are triggered any time any action takes place in the collaboration flow. These events get fired any time any entity a user belongs to is modified, created, or removed.
Global events can be subscribed to via the EventManager.subscribe function.
Below is a list of all global events.
documentLoaded
#
Triggered whenever a new document is loaded/displayed in the viewer.
Callback function is passed the Document instance that was loaded.
documentChanged
#
Triggered any time a document instance changed. This includes:
- Any time a new user joins the document, or a user connects/disconnects from the document
- Any time an annotation belonging to the document is added/edited/removed/marked as read
- Any time the document name or 'isPublic' flag is updated
Callback function is passed the Document instance that was changed.
documentDeleted
#
Triggered when a document is deleted.
Callback is passed the ID of the document that was deleted.
annotationAdded
#
Triggered when an annotation is added to the currently opened document.
Callback is passed the instance of Annotation that was created.
annotationChanged
#
Triggered whenever an annotation is changed on the currently opened document. This event is not triggered when an annotation is marked as read.
Callback is passed the instance of Annotation that was changed.
annotationMarkedAsRead
#
Triggered whenever an annotation is marked as read by the current user.
Callback is passed the instance of Annotation that was read.
annotationDeleted
#
Triggered whenever an annotation is deleted on the currently opened document.
Callback is passed the ID of the annotation that was deleted.
snapshotAdded
#
Triggered whenever a snapshot of the currently opened document is created.
Callback is passed an instance of the Snapshot that was created.
snapshotChanged
#
Triggered whenever a snapshot of the currently opened document is edited.
Callback is passed an instance of the Snapshot that was edited.
snapshotDeleted
#
Triggered whenever a snapshot of the currently opened document is deleted.
Callback is passed the ID of the snapshot that was deleted.
snapshotRestored
#
Triggered whenever the currently opened document is restored to a snapshot.
Callback is passed an instance of the Snapshot that was restored. A second sync
parameter is also passed, more info on that here.
userLoggedIn
#
Triggered whenever a user is logged in via loginAnonymously, loginWithPassword, or loginWithToken.
Callback is passed an instance of User, representing the user that was logged in.
inviteReceived
#
Triggered whenever the currently logged in user receives an invite to a document.
Callback is passed the Document that the user was invited to.
mentionAdded
#
Triggered whenever the the user is mentioned in an annotation.
Callback is passed an instance of Mention.
mentionDeleted
#
Triggered whenever an annotation the user is mentioned in is deleted.
Callback is passed the ID of the mention that was deleted.
enteredPreviewMode
#
Triggered whenever the viewer goes into preview mode. Preview mode is entered when a user is viewing a snapshot.
Callback is passed an instance of Snapshot that is being previewed.
exitedPreviewMode
#
Triggered whenever the viewer leaves preview mode.
Callback is passed an instance of Snapshot that was being previewed.
annotationSizeError
#
Triggered when maxAnnotationSize is set and an annotation is created that is larger than the threshold.
Callback is passed the instance of Annotation that was created.
connectedUsersChanged
#
Only triggered when the connected users feature is turned on.
This event is triggered when:
- A user connects or disconnects to the currently opened document
- A user changes the page they are currently viewing
Callback is passed three parameters:
users
(User[]) A list of users that are currently viewing the document.document
(Document) The document the users connected to.action
("ADD", "DELETE", or "EDIT) The action that triggered this event
scrollSyncSessionsChanged
#
Triggered whenever a scroll sync session is created or destroyed.
Callback is passed an array of ScrollSyncSession that are available to join.
joinedScrollSyncSession
#
Triggered whenever a user joins a scroll sync session.
Callback is passed the ScrollSyncSession that the user joined.
leftScrollSyncSession
#
Triggered whenever a user leaves a scroll sync session.
Callback is passed the ID of the session that was left.
annotationPermissionError
#
Triggered when a user tried to add, edit, delete, or read an annotation without proper permissions.
Callback is passed two arguments:
action
(string) The action the user tried to perform. One of: 'ADD' | 'DELETE' | 'MODIFY' | 'READ'annotation
(Annotation - optional) If available, the annotation instance they tried to alter is provided.
documentPermissionError
#
Triggered when a user tried to add, edit, delete, read, or invite to a document without proper permissions.
Callback is passed two arguments:
action
(string) The action the user tried to perform. One of: 'ADD' | 'DELETE' | 'MODIFY' | 'READ' | 'INVITE'document
(Document - optional) If available, the document instance they tried to alter is provided.
snapshotPermissionError
#
Triggered when a user tried to add, edit, delete, read, or restore a snapshot without proper permissions.
Callback is passed two arguments:
action
(string) The action the user tried to perform. One of: 'ADD' | 'DELETE' | 'MODIFY' | 'READ' | 'RESTORE'snapshot
(Snapshot - optional) If available, the snapshot instance they tried to alter is provided.
#
Entity Specific EventsIn addition to the global events documented above, you can also subscribe to events on an entity level.
Call the subscribe
function on the entity to subscribe to the events.
#
Document eventsInstances of Document triggers the following events:
onChange
Triggered when the document instance changes. Callback function is passed the instance of the documentonDestroy
Triggered when the Document is deleted. Callback function accepts the ID of the deleted documentsnapshotAdded
Triggered when a snapshot of this document is created. Callback function accepts the Snapshot that was created.connectedUsersChanged
Triggered when a user connects, disconnects, or views a new page of this document. Callback function accepts a list of users that are connected, and the action that triggered the event.
#
Annotation eventsInstances of Annotation triggers the following events:
markedAsRead
Triggered when the annotation is marked as read. Callback function accepts the Annotation as a parameter.onChange
Triggered when the annotation instance changes. Callback function is passed the instance of the annotationonDestroy
Triggered when the Annotation is deleted. Callback function accepts the ID of the deleted annotation
#
Mention eventsInstances of Mention triggers the following events:
markedAsRead
Triggered when the Mention is marked as read. Callback function accepts the Mention as a parameter.onChange
Triggered when the Mention instance changes. Callback function is passed the instance of the mention.onDestroy
Triggered when the Mention is deleted. Callback function accepts the ID of the deleted mention
#
Snapshot eventsInstances of Snapshot triggers the following events:
restored
Triggered when the Snapshot is restored. Callback function accepts the Snapshot as a parameter.onChange
Triggered when the Snapshot instance changes. Callback function is passed the instance of the snapshot.onDestroy
Triggered when the Snapshot is deleted. Callback function accepts the ID of the deleted snapshot.
#
Unsubscribing from eventsEvery subscribe
function returns a function that can be called to unsubscribe from the event.
#
Listening to an event only onceTo immediately unsubscribe from an event as soon as its triggered, call the unsubscribe function inside the callback function.