Collaborator
Defined in: collab.ts:155
Makes a single editor a live collaborator on a shared document.
Typical usage:
const net = createMemoryNetwork({ origin: baseDoc });const me = new Collaborator({ peer: { id: 'alice' }, editor, transport: net.connect() });me.onChange((s) => render(s)); // react to confirmed/pending changesme.setPresence({ status: 'editing' }); // broadcast awareness// ...local edits flow automatically via the editor's transactions.Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Collaborator(options): Collaborator;Defined in: collab.ts:178
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options | CollaboratorOptions |
Returns
Section titled “Returns”Collaborator
Properties
Section titled “Properties”| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
ledger | readonly | TransactionLedger | The confirmed (canonical) log this client has applied — the shared source of truth, for diff/serialize. | collab.ts:159 |
peer | readonly | Peer | - | collab.ts:156 |
presence | readonly | PresenceTracker | - | collab.ts:157 |
Accessors
Section titled “Accessors”confirmedDocument
Section titled “confirmedDocument”Get Signature
Section titled “Get Signature”get confirmedDocument(): DocumentNode;Defined in: collab.ts:224
The confirmed/canonical document (excludes un-acked local edits).
Returns
Section titled “Returns”DocumentNode
document
Section titled “document”Get Signature
Section titled “Get Signature”get document(): DocumentNode;Defined in: collab.ts:219
The optimistic document currently shown in the editor (confirmed + pending).
Returns
Section titled “Returns”DocumentNode
Get Signature
Section titled “Get Signature”get peers(): PeerPresence[];Defined in: collab.ts:229
Other peers’ presence (what you render as remote cursors).
Returns
Section titled “Returns”status
Section titled “status”Get Signature
Section titled “Get Signature”get status(): CollabStatus;Defined in: collab.ts:214
Returns
Section titled “Returns”Methods
Section titled “Methods”destroy()
Section titled “destroy()”destroy(): void;Defined in: collab.ts:263
Detach from the editor and transport, announcing departure.
Returns
Section titled “Returns”void
onChange()
Section titled “onChange()”onChange(listener): () => void;Defined in: collab.ts:238
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
listener | CollabChangeListener |
Returns
Section titled “Returns”() => void
patchPresence()
Section titled “patchPresence()”patchPresence(patch): void;Defined in: collab.ts:252
Merge a partial patch into this client’s awareness state and broadcast it.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
patch | Partial<PresenceState> |
Returns
Section titled “Returns”void
setPresence()
Section titled “setPresence()”setPresence(state): void;Defined in: collab.ts:246
Replace this client’s awareness state and broadcast it.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
state | PresenceState |
Returns
Section titled “Returns”void
start()
Section titled “start()”start(): void;Defined in: collab.ts:197
Begin the handshake (send hello). Called automatically unless autoStart: false.
Returns
Section titled “Returns”void
sync()
Section titled “sync()”sync(): void;Defined in: collab.ts:258
Request any canonical records this client is missing (late join / reconnect).
Returns
Section titled “Returns”void
versionVector()
Section titled “versionVector()”versionVector(): VersionVector;Defined in: collab.ts:234
This client’s view vector — the highest seq seen per source.