attachDocument

fun attachDocument(document: Document, initialPresence: P = emptyMap(), syncMode: Client.SyncMode = SyncMode.Realtime, schema: String? = null, disableGC: Boolean = false, disablePresence: Boolean = false): Deferred<OperationResult>

Attaches the given Document to this Client. It tells the server that this Client will synchronize the given document.

Parameters

initialPresence

: is the initial presence of the client.

syncMode

: defines the synchronization mode of the document.

schema

: is the schema of the document. It is used to validate the document.

disableGC

: declares that this attachment will not produce or consume tombstones. The server skips minVV tracking and omits the response VersionVector for this client. Use only with Counter or primitive workloads where no client consumes tombstones; misuse on a document that uses Tree, Text, or Array deletions leads to undefined GC behavior on this client. Controls only the wire contract and is distinct from any local-only Document GC pass.

disablePresence

: declares that this document does not produce, consume, or store presence. When true, the initial presence is not pushed and presence updates from Document.updateAsync are dropped. Honored on first attach only; the server persists the value and returns it on subsequent attaches.


fun attachDocument(document: Document, initialPresence: P = emptyMap(), syncMode: Client.SyncMode = SyncMode.Realtime, schema: String? = null, disableGC: Boolean = false, disablePresence: Boolean = false, initialRoot: InitialRoot): Deferred<OperationResult>

Attaches the given Document to this Client and initializes missing root keys.

The authoritative server response is applied first. Each initialRoot initializer is then invoked only if its map key is absent, and receives that key as its argument. All invoked initializers form one atomic local change. This change runs as a history-exempt skipHistory update, so it never enters the undo/redo history. Concurrent first attachments are not globally serialized; their ordinary CRDT changes converge through normal conflict resolution.

The document is marked ResourceStatus.Attached and registered with this client BEFORE the initialRoot initializers run, so a throwing initializer leaves the document attached and detachable rather than rolled back; the returned deferred still resolves to failure, and history is already cleared. A user edit made after the ResourceStatus.Attached event while an initializer is still running keeps its undo entry, index-reconciled against the initializer change. Document events emitted by the initializer change are always preceded by the ResourceStatus.Attached event.

Parameters

initialPresence

The initial presence of the client.

syncMode

The synchronization mode of the document.

schema

The schema used to validate the document.

disableGC

declares that this attachment will not produce or consume tombstones. The server skips minVV tracking and omits the response VersionVector for this client. Use only with Counter or primitive workloads where no client consumes tombstones; misuse on a document that uses Tree, Text, or Array deletions leads to undefined GC behavior on this client. Controls only the wire contract and is distinct from any local-only Document GC pass.

disablePresence

Whether this attachment opts out of presence.

initialRoot

Initializers for root keys absent from the authoritative server response.