am_sync_state_new: Create a new sync state

View source: R/sync.R

am_sync_state_newR Documentation

Create a new sync state

Description

Creates a new synchronization state for managing communication with a peer. The sync state tracks what changes have been sent and received, enabling efficient incremental synchronization.

Usage

am_sync_state_new()

Details

IMPORTANT: Sync state is document-independent. The same sync state is used across multiple sync message exchanges with a specific peer. The document is passed separately to am_sync_encode() and am_sync_decode().

Value

An external pointer to the sync state with class "am_syncstate".

Examples

# Create two documents
doc1 <- am_create()
doc2 <- am_create()

# Create sync states for each peer
sync1 <- am_sync_state_new()
sync2 <- am_sync_state_new()

# Use with am_sync_encode() and am_sync_decode()

am_close(doc1)
am_close(doc2)


automerge documentation built on Feb. 5, 2026, 5:08 p.m.