Skip to main content
protected setState(patch): Promise<State>
Merge patch into the persistent state and return the merged result. The merge is a recursive JSON merge patch (RFC 7396): top-level keys in patch are merged in, nested objects are deep-merged, and a null value deletes that key. The merge runs in a storage transaction, and onStateChanged fires after it commits. The committed patch is also pushed to connected clients subscribed to the state stream — no broadcast call needed. Values must be storage-codec-safe (JSON-native values plus Date, Map, Set, ArrayBuffer/TypedArray, BigInt, RegExp); functions, class instances, or circular references throw a CodecError. Parameters Returns Promise<State> The full state after the merge.