The type of the value contained in the document
The document to update
The heads representing the point in history to make the change
Either a message or a ChangeOptions for the new change
Optional
callback: next.ChangeFn<T>A ChangeFn
to be used if options
was a string
Generated using TypeDoc
Make a change to the document as it was at a particular point in history
Remarks
This function is similar to change but allows you to make changes to the document as if it were at a particular point in time. To understand this imagine a document created with the following history:
ChangeAt produces an equivalent history, but without having to create a fork of the document. In particular the
newHeads
field of the returned ChangeAtResult will be the same asheadsOnFork
.Why would you want this? It's typically used in conjunction with diff to reconcile state which is managed concurrently with the document. For example, if you have a text editor component which the user is modifying and you can't send the changes to the document synchronously you might follow a workflow like this:
Now from time to time reconcile the editor state and the document
oldHeads
changeAt(doc, oldHeads, ...)
before
argument and the heads of the entire document as theafter
argument.