Constructor
new ve.dm.SurfaceSynchronizer(surface, documentId, [config])
#
DataModel surface synchronizer.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
surface |
ve.dm.Surface | Surface model to synchronize |
|||||||||||||
documentId |
string | Document ID |
|||||||||||||
config |
Object |
optional |
Configuration options Properties:
|
- Mixes in:
- Source:
Methods
addToHistory()
#
applyChange()
#
applyNewSelections(newSelections, [changeOrTx])
#
Translate incoming selections by change, then apply them and fire authorSelect
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
newSelections |
Object | Each author (key) maps to a new incoming |
|
changeOrTx |
ve.dm.Change | ve.dm.Transaction |
optional |
Object to translate over, if any |
Fires:
destroy()
#
Destroy the synchronizer
getAuthorData([authorId]) → {Object}
#
Get author data object
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
authorId |
number |
optional |
Author ID, defaults to current author |
Returns:
Author object, containing 'name' and 'color'
- Type
- Object
getChangeSince()
#
logEvent()
#
onInitDoc(data)
#
Respond to an initDoc event from the server, catching us up on the prior history of the document.
Parameters:
Name | Type | Description |
---|---|---|
data |
Object |
Properties: |
Fires:
onNewChange(serializedChange)
#
Respond to a newChange event from the server, signalling a newly committed change
If the commited change is by another author, then:
- Rebase uncommitted changes over the committed change
- If there is a rebase rejection, then apply its inverse to the document
- Apply the rebase-transposed committed change to the document
- Rewrite history to have the committed change followed by rebased uncommitted changes
If the committed change is by the local author, then it is already applied to the document and at the correct point in the history: just move the commit pointer.
Parameters:
Respond to a newChange event from the server, signalling a newly committed change
If the commited change is by another author, then:
- Rebase uncommitted changes over the committed change
- If there is a rebase rejection, then apply its inverse to the document
- Apply the rebase-transposed committed change to the document
- Rewrite history to have the committed change followed by rebased uncommitted changes
If the committed change is by the local author, then it is already applied to the document and at the correct point in the history: just move the commit pointer.
onRegistered(data)
#
Respond to a "registered" event from the server
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object |
Properties:
|
Fires:
onSurfaceHistory()
#
Respond to transactions happening on the document. Ignores transactions applied by SurfaceSynchronizer itself.
onSurfaceSelect()
#
Respond to selection changes.
pauseChanges()
#
Pause sending/receiving changes
Fires:
removeFromHistory()
#
resumeChanges()
#
Resume sending/receiving changes
Fires:
sendChange()
#
submitChange()
#
unapplyChange()
#
Events
disconnect()
#
initDoc(error)
#
Parameters:
Name | Type | Description |
---|---|---|
error |
Error | Error, if there was a problem initializing the document |
pause()
#
The synchronizer is paused or resumes