-
connectionStateChanged
-
Fired when connection state has been changed.
Parameters:
Example
syncClient.on('connectionStateChanged', function(newState) {
console.log('Received new connection state: ' + newState);
});
-
removed
-
Fired when the document is removed, whether the remover was local or remote.
Parameters:
Name |
Type |
Description |
args |
Object
|
Arguments provided with the event.
Properties
Name |
Type |
Description |
isLocal |
Boolean
|
Equals 'true' if document was removed by local actor, 'false' otherwise. |
|
Example
document.on('removed', function(args) {
console.log('Document ' + document.sid + ' was removed');
console.log('args.isLocal:', args.isLocal);
});
-
updated
-
Fired when the document's contents have changed, whether the updater was local or remote.
Parameters:
Name |
Type |
Description |
args |
Object
|
Arguments provided with the event.
Properties
Name |
Type |
Description |
value |
Object
|
A snapshot of the document's new contents. |
isLocal |
Boolean
|
Equals 'true' if document was updated by local actor, 'false' otherwise. |
|
Example
document.on('updated', function(args) {
console.log('Document ' + document.sid + ' was updated');
console.log('args.value: ', args.value);
console.log('args.isLocal: ', args.isLocal);
});
-
itemAdded
-
Fired when a new item appears in the list, whether its creator was local or remote.
Parameters:
Name |
Type |
Description |
args |
Object
|
Arguments provided with the event.
Properties
Name |
Type |
Description |
item |
ListItem
|
Added item. |
isLocal |
Boolean
|
Equals 'true' if item was added by local actor, 'false' otherwise. |
|
Example
list.on('itemAdded', function(args) {
console.log('List item ' + args.item.index + ' was added');
console.log('args.item.value:', args.item.value);
console.log('args.isLocal:', args.isLocal);
});
-
itemRemoved
-
Fired when a list item is removed, whether the remover was local or remote.
Parameters:
Name |
Type |
Description |
args |
Object
|
Arguments provided with the event.
Properties
Name |
Type |
Description |
index |
Number
|
The index of the removed item. |
isLocal |
Boolean
|
Equals 'true' if item was removed by local actor, 'false' otherwise. |
value |
Object
|
In case item was removed by a remote actor, contains a snapshot of item data before removal. |
|
Example
list.on('itemRemoved', function(args) {
console.log('List item ' + args.index + ' was removed');
console.log('args.value:', args.value);
console.log('args.isLocal:', args.isLocal);
});
-
itemUpdated
-
Fired when a list item is updated (not added or removed, but changed), whether the updater was local or remote.
Parameters:
Name |
Type |
Description |
args |
Object
|
Arguments provided with the event.
Properties
Name |
Type |
Description |
item |
ListItem
|
Updated item. |
isLocal |
Boolean
|
Equals 'true' if item was updated by local actor, 'false' otherwise. |
|
Example
list.on('itemUpdated', function(args) {
console.log('List item ' + args.item.index + ' was updated');
console.log('args.item.value:', args.item.value);
console.log('args.isLocal:', args.isLocal);
});
-
removed
-
Fired when a list is deleted entirely, by any actor local or remote.
Parameters:
Name |
Type |
Description |
args |
Object
|
Arguments provided with the event.
Properties
Name |
Type |
Description |
isLocal |
Boolean
|
Equals 'true' if list was removed by local actor, 'false' otherwise. |
|
Example
list.on('removed', function(args) {
console.log('List ' + list.sid + ' was removed');
console.log('args.isLocal:', args.isLocal);
});
-
itemAdded
-
Fired when a new item appears in the map, whether its creator was local or remote.
Parameters:
Name |
Type |
Description |
args |
Object
|
Arguments provided with the event.
Properties
Name |
Type |
Description |
item |
MapItem
|
Added item. |
isLocal |
Boolean
|
Equals 'true' if item was added by local actor, 'false' otherwise. |
|
Example
map.on('itemAdded', function(args) {
console.log('Map item ' + args.item.key + ' was added');
console.log('args.item.value:', args.item.value);
console.log('args.isLocal:', args.isLocal);
});
-
itemRemoved
-
Fired when a map item is removed, whether the remover was local or remote.
Parameters:
Name |
Type |
Description |
args |
Object
|
Arguments provided with the event.
Properties
Name |
Type |
Description |
key |
String
|
The key of the removed item. |
isLocal |
Boolean
|
Equals 'true' if item was removed by local actor, 'false' otherwise. |
value |
Object
|
In case item was removed by a remote actor, contains a snapshot of item data before removal. |
|
Example
map.on('itemRemoved', function(args) {
console.log('Map item ' + args.key + ' was removed');
console.log('args.value:', args.value);
console.log('args.isLocal:', args.isLocal);
});
-
itemUpdated
-
Fired when a map item is updated (not added or removed, but changed), whether the updater was local or remote.
Parameters:
Name |
Type |
Description |
args |
Object
|
Arguments provided with the event.
Properties
Name |
Type |
Description |
item |
MapItem
|
Updated item. |
isLocal |
Boolean
|
Equals 'true' if item was updated by local actor, 'false' otherwise. |
|
Example
map.on('itemUpdated', function(args) {
console.log('Map item ' + args.item.key + ' was updated');
console.log('args.item.value:', args.item.value);
console.log('args.isLocal:', args.isLocal);
});
-
removed
-
Fired when a map is deleted entirely, by any actor local or remote.
Parameters:
Name |
Type |
Description |
args |
Object
|
Arguments provided with the event.
Properties
Name |
Type |
Description |
isLocal |
Boolean
|
Equals 'true' if map was removed by local actor, 'false' otherwise. |
|
Example
map.on('removed', function(args) {
console.log('Map ' + map.sid + ' was removed');
console.log('args.isLocal:', args.isLocal);
});
-
messagePublished
-
Fired when a Message is published to the Stream either locally or by a remote actor.
Parameters:
Name |
Type |
Description |
args |
Object
|
Arguments provided with the event.
Properties
Name |
Type |
Description |
message |
StreamMessage
|
Published message. |
isLocal |
Boolean
|
Equals 'true' if message was published by local code, 'false' otherwise. |
|
Example
stream.on('messagePublished', function(args) {
console.log('Stream message published');
console.log('Message SID: ' + args.message.sid);
console.log('Message value: ', args.message.value);
console.log('args.isLocal:', args.isLocal);
});
-
removed
-
Fired when a stream is removed entirely, whether the remover was local or remote.
Parameters:
Name |
Type |
Description |
args |
Object
|
Arguments provided with the event.
Properties
Name |
Type |
Description |
isLocal |
Boolean
|
Equals 'true' if stream was removed by local code, 'false' otherwise. |
|
Example
stream.on('removed', function(args) {
console.log('Stream ' + stream.sid + ' was removed');
console.log('args.isLocal:', args.isLocal);
});