Skip to content
Developer Preview

SessionStateStore

Last-write-wins per family, in arrival order.

Cursors are opaque strings and MUST NOT be parsed or ordered, so ordering here is by arrival: the server emits view events in cursor order on every connection, and a page’s events are ascending. The one cursor use is EXACT-EQUALITY replay de-duplication, and it remembers only the family’s LATEST cursor — it refuses only a back-to-back replay of the family’s most recent event. The splice caller must skip already-applied page events itself, which it does by construction: the splice pages forward from after (the last delivered cursor) and discards paged events at cursors >= next as duplicates of the live buffer, so no sanctioned path re-delivers an older event. No relational comparison exists: string order diverges from cursor order at every digit rollover (“v:s:10” < “v:s:9” as strings), which would drop genuinely newer events.

Method Signature Stability Description
constructor new SessionStateStore()
apply apply(family: string, value: StateValue<V>, cursor?: string): StateApplyOutcome<V> Apply a state event. cursor is the event’s viewCursor; when omitted (a snapshot seed, which carries one cursor for the whole state) the value is taken unconditionally.
families families(): readonly string[] Every family that holds a value, in insertion order.
get get(family: string): StateValue<V> | undefined Read a family. undefined means no fact has ever landed — distinct from null, which means a fact cleared it. Absent is never fabricated.
has has(family: string): boolean
seed seed(entries: Iterable<readonly [string, StateValue<V>]>, cursor?: string): void Seed from a snapshot’s state block: authoritative, replaces wholesale.
Source

clients/sdk-ts/src/fold/state-store.ts:52

{
"kind": "Class",
"canonicalPath": "SessionStateStore"
}