Skip to content

YjsProvider

Defined in: yjs/src/peerborne-yjs.ts:434

  • CRDTProvider<Doc, Uint8Array, (doc) => void>

new YjsProvider(): YjsProvider

YjsProvider

getHistory(document): Uint8Array

Defined in: yjs/src/peerborne-yjs.ts:462

Gets all changes for the document.

Doc

CRDT document to inspect.

Uint8Array

CRDTProvider.getHistory


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())

Doc

CRDT document to snapshot.

Uint8Array

A snapshot representation. If the snapshot format differs from the incremental change format, implement applySnapshot() as well.

CRDTProvider.getSnapshot


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.

Doc

CRDT document to change.

string

A description of the change made.

(doc) => void

A function that modifies a CRDT document (provided as a parameter). This function will be run as a part of .localChange(...)

[Doc, Uint8Array<ArrayBufferLike>]

CRDTProvider.localChange


newDocument(): Doc

Defined in: yjs/src/peerborne-yjs.ts:437

Create a new empty (contains the equivalent of {}) CRDT document.

Doc

CRDTProvider.newDocument


remoteChange(document, changes): Doc

Defined in: yjs/src/peerborne-yjs.ts:454

Apply CRDT document changes made by a remote peer.

Doc

CRDT document to update.

Uint8Array

An object describing changes made by a peer. CRDT-specific.

Doc

CRDTProvider.remoteChange