Skip to main content
onState(listener): () => void
Subscribe to state updates; returns an unsubscribe function. Parameters Returns () => void

The Local Copy

The client keeps a local copy of the agent’s state. Every connection, reconnects included, starts the copy from a snapshot. Each setState on the agent then arrives as an RFC 7396 merge patch. Each replaceState arrives as a new snapshot. A listener receives the whole copy after every change. A listener added after the first snapshot is called at once with the current copy.