YjsProvider
Defined in: yjs/src/peerborne-yjs.ts:434
Implements
Section titled “Implements”CRDTProvider<Doc,Uint8Array, (doc) =>void>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new YjsProvider():
YjsProvider
Returns
Section titled “Returns”YjsProvider
Methods
Section titled “Methods”getHistory()
Section titled “getHistory()”getHistory(
document):Uint8Array
Defined in: yjs/src/peerborne-yjs.ts:462
Gets all changes for the document.
Parameters
Section titled “Parameters”document
Section titled “document”Doc
CRDT document to inspect.
Returns
Section titled “Returns”Uint8Array
Implementation of
Section titled “Implementation of”CRDTProvider.getHistory
getSnapshot()
Section titled “getSnapshot()”getSnapshot(
document):Uint8Array
Defined in: yjs/src/peerborne-yjs.ts:470
Get a compacted state snapshot of the document. Used for onboarding new members without replaying individual changes.
For Yjs: Y.encodeStateAsUpdateV2(doc) (directly applicable via remoteChange())
For Automerge: Automerge.save(doc) (requires applySnapshot() since save format
differs from the incremental change format used by remoteChange())
Parameters
Section titled “Parameters”document
Section titled “document”Doc
CRDT document to snapshot.
Returns
Section titled “Returns”Uint8Array
A snapshot representation. If the snapshot format differs from the
incremental change format, implement applySnapshot() as well.
Implementation of
Section titled “Implementation of”CRDTProvider.getSnapshot
localChange()
Section titled “localChange()”localChange(
document,message,changeFn): [Doc,Uint8Array<ArrayBufferLike>]
Defined in: yjs/src/peerborne-yjs.ts:440
Apply locally made changes to provided CRDT document as defined by changeFn.
Parameters
Section titled “Parameters”document
Section titled “document”Doc
CRDT document to change.
message
Section titled “message”string
A description of the change made.
changeFn
Section titled “changeFn”(doc) => void
A function that modifies a CRDT document (provided as a parameter).
This function will be run as a part of .localChange(...)
Returns
Section titled “Returns”[Doc, Uint8Array<ArrayBufferLike>]
Implementation of
Section titled “Implementation of”CRDTProvider.localChange
newDocument()
Section titled “newDocument()”newDocument():
Doc
Defined in: yjs/src/peerborne-yjs.ts:437
Create a new empty (contains the equivalent of {}) CRDT document.
Returns
Section titled “Returns”Doc
Implementation of
Section titled “Implementation of”CRDTProvider.newDocument
remoteChange()
Section titled “remoteChange()”remoteChange(
document,changes):Doc
Defined in: yjs/src/peerborne-yjs.ts:454
Apply CRDT document changes made by a remote peer.
Parameters
Section titled “Parameters”document
Section titled “document”Doc
CRDT document to update.
changes
Section titled “changes”Uint8Array
An object describing changes made by a peer. CRDT-specific.
Returns
Section titled “Returns”Doc
Implementation of
Section titled “Implementation of”CRDTProvider.remoteChange