Shared Documents
SharedArray
Defines an array that can be shared between multiple clients.
Members
changes Observable<SharedArrayChanges>
Gets an observable that resolves whenever the array is changed.
deepChanges Observable<SharedTypeChanges[]>
Gets an observable that resolves whenever this array or any children are changed.
doc SharedDocument
The document that the map is associated with.
length number
Gets the number of elements in the array.
parent SharedType
The type that this map is stored in.
size number
Gets the number of elements in the array.
[iterator](): IterableIterator<T>
Gets an iterator for the items in the array.
applyDelta(delta: SharedArrayOp[]): void
Applies the given delta to the array.
The first parameter is a SharedArrayOp[] and is the delta to apply.
clone(): SharedArray
Creates a new shared array that is a clone of this array.
delete(index: number, count: number): void
Deletes the given number of items, starting at the given index.
The first parameter is a number and is the index of the first item to be deleted.
The second parameter is a number and is the number of items to delete.
filter(predicate: (value: T,index: number,array: SharedArray) => boolean): T[]
Creates a new JavaScript array with all elements that pass the test implemented by the provided function.
The first parameter is a (value: T,index: number,array: SharedArray) => boolean and is the function to execute.
forEach(callback: (value: T,index: number,array: SharedArray) => void): void
Execute the given callback function for each item in the array.
The first parameter is a (value: T,index: number,array: SharedArray) => void and is the function to execute.
insert(index: number, items: T[]): void
Insert items at the given index.
The first parameter is a number and is the index to insert the items at. Items at or after this index will be pushed back to make space for the new items. If the index is greater than the length of the array, then the items are appended to the end of the array.
The second parameter is a T[] and is the items to insert.
map(callback: (value: T,index: number,array: SharedArray) => T): T[]
Creates a new JavaScript array with the results of calling a provided function on every element in this array.
The first parameter is a (value: T,index: number,array: SharedArray) => T and is the function to execute.
slice(start?: number, end?: number): T[]
Gets a range of items from the array. Negative indexes can be used to start from the end of the array.
The first parameter is optional and is a number and is the index of the first item to retrieve.
The second parameter is optional and is a number and is the index of the last item to retrieve.
splice(start: number, deleteCount: number, ...items: T[]): T[]
Changes the contents of the array by removing or replacing existing elements and/or adding new elements. Returns a JavaScript array containing the removed elements.
The first parameter is a number and is the index at which to start changing the array.
The second parameter is a number and is the number of elements in the array to remove from start.
Each other parameter is a T and are the elements to add to the array.
SharedArrayChanges
An object that represents changes that occurred in a shared array.
Members
delta SharedArrayOp[]
The array of changes that were made to the array.
target SharedArray
The array that was changed.
type "array"
SharedArrayOp
The possible individual changes that were made to a shared array.
A SharedArrayOp can be one of the following values:
SharedDocument
Defines an interface for objects that are able to synchronize data between multiple clients.
Members
address string
The address of the document. If null, then the document is stored locally.
branch string
The branch that was loaded for the document.
clientId number
The ID of the remote client that the document is associated with.
closed boolean
onClientError Observable<ClientError>
Gets the observable list of client errors from the document. That is, errors that were caused by the client's behavior.
onError Observable<any>
Gets an observable list of errors from the partition. That is, errors that the client cannot handle.
onEvents Observable<Action[]>
Gets the observable list of remote events from the partition.
onStatusUpdated Observable<StatusUpdate>
Gets the observable list of status updates from the partition.
onUpdates Observable<string[]>
Gets the observable list of updates from the partition.
onVersionUpdated Observable<CurrentVersion>
Gets an observable list that resolves whenever the partition state version is updated.
recordName string
The name of the record that the document is stored under. If null, then the document is public.
applyStateUpdates(updates: InstUpdate[]): void
Applies the given inst updates to the document.
The first parameter is a InstUpdate[] and is the updates to apply.
applyUpdates(updates: string[]): void
Applies the given raw updates to the document.
The first parameter is a string[] and is the updates to apply.
connect(): void
Tells the document to connect to its backing store.
createArray(): SharedArray
Creates a new array that can be shared between multiple clients.
createText(): SharedText
Creates a new text object that can be shared between multiple clients.
getArray(name: string): SharedArray
Gets a top-level array that can be used to store a list of items.
The first parameter is a string and is the name of the array.
getStateUpdate(): InstUpdate
Gets the update that represents the current state of the document.
getText(name: string): SharedText
Gets a top-level text object that can be used to store rich text.
The first parameter is a string and is the name of the text.
transact(callback: () => void): void
Batches changes that occur within the given callback function into a single transaction. This makes multiple updates more efficient.
The first parameter is a () => void and is the function to execute.
unsubscribe(): void
SharedMap
Defines a map that can be shared between multiple clients.
Members
changes Observable<SharedMapChanges>
Gets an observable that resolves whenever the map is changed.
deepChanges Observable<SharedTypeChanges[]>
Gets an observable that resolves whenever this map or any children are changed.
doc SharedDocument
The document that the map is associated with.
parent SharedType
The type that this map is stored in.
size number
Gets the number of keys that are in the map.
[iterator](): IterableIterator<[string, T]>
Gets an iterator for the key/value pairs stored in the map.
clear(): void
Clears the map.
delete(key: string): void
Deletes the given key from the map.
The first parameter is a string and deletes the given key.
entries(): IterableIterator<[string, T]>
Gets an iterator for the key/value pairs stored in the map.
has(key: string): boolean
Determines if the given key exists in the map.
The first parameter is a string and is the key.
keys(): IterableIterator<string>
Gets an iterator for the keys stored in the map.
toJSON(): object
Transforms this map into an object that can be serialized to JSON.
values(): IterableIterator<T>
Gets an iterator for the values stored in the map.
SharedText
Defines an object that represents rich text that can be shared between multiple clients.
Members
changes Observable<SharedTextChanges>
Gets an observable that resolves whenever the array is changed.
deepChanges Observable<SharedTextChanges[]>
Gets an observable that resolves whenever this array or any children are changed.
doc SharedDocument
The document that the map is associated with.
length number
Gets the length of the string in UTF-16 code units.
parent SharedType
The type that this map is stored in.
applyDelta(delta: SharedTextDelta): void
Applies the given delta to the text.
The first parameter is a SharedTextDelta and is the delta to apply.
clone(): SharedText
Creates a new shared array that is a clone of this array.
decodeRelativePosition(position: RelativePosition): number
Gets the index that the given relative position is associated with.
The first parameter is a RelativePosition and is the relative position to decode.
delete(index: number, count: number): void
Deletes the given number of items, starting at the given index.
The first parameter is a number and is the index of the first item to be deleted.
The second parameter is a number and is the number of items to delete.
encodeRelativePosition(index: number, assoc?: number): RelativePosition
Creates a relative position that is fixed to the code point at the given index.
The first parameter is a number and is the index of the character to create the relative position for.
The second parameter is optional and is a number and is the association of the relative position to the character. < 0 is before, >= 0 is after.
insert(index: number, text: string, attribtues?: Record): void
Insert text at the given index. Optionally apply formatting to the inserted text.
The first parameter is a number and is the index to insert the text at.
The second parameter is a string and is the text to insert.
The third parameter is optional and is a Record and is the formatting attributes to apply to the inserted text.
slice(start?: number, end?: number): string
Gets a range of text from this object. Negative indexes can be used to start from the end of the string.
The first parameter is optional and is a number and is the index of the first code point to retrieve.
The second parameter is optional and is a number and is the index of the last code point to retrieve.
toDelta(): SharedTextDelta
Converts this text into a delta that can be applied to another text object.
toJSON(): string
Transforms this text into a string that can be serialized to JSON.
toString(): string
Creates a new JavaScript string that is a clone of this text.
SharedTextChanges
An object that represents changes that occurred in a shared text object.
Members
delta SharedTextDelta
The changes that were made to the array.
target SharedText
The text that was changed.
type "text"
SharedTextDelta
The array of changes that were made to the text.
SharedTextOp
The possible individual changes that were made to the text.
A SharedTextOp can be one of the following values:
SharedType
Defienes a type that can be shared between multiple clients. This can be a map, array, or text.
A SharedType can be one of the following values:
SharedTypeChanges
Defines the type of changes that can occur in a shared document.
This can be a change to a map, array, or text.
A SharedTypeChanges can be one of the following values: