Skip to content

MemoryStateStorage

Defined in: src/client/state-storage.ts:102

State held for the lifetime of the instance and shared with nothing.

For tests and for environments with no localStorage, where a client is alone and a reload starts from nothing.

implements StateStorage

new MemoryStateStorage(): MemoryStateStorage

MemoryStateStorage

discard(key): void

Defined in: src/client/state-storage.ts:123

The same as remove: this store publishes nothing at all.

string

void

StateStorage.discard


get(key): SessionState | null

Defined in: src/client/state-storage.ts:106

The state, or null where nothing is signed in within this store’s reach.

string

SessionState | null

StateStorage.get


remove(key): void

Defined in: src/client/state-storage.ts:117

Removes the state, and anything this store publishes beyond this origin.

What signing out does: the user ended the sign-in, so a sibling reading a shared record must stop seeing one.

string

void

StateStorage.remove


set(key, state): void

Defined in: src/client/state-storage.ts:112

string

Omit<SessionState, "held">

void

StateStorage.set


subscribe(key, listener): () => void

Defined in: src/client/state-storage.ts:137

Fires when the state changes, which here means when something writes to this instance.

Nothing outside the process can reach a Map, so a medium is not what makes this worth having: two clients can be handed the same instance, and this is how the one that did not write finds out. Each listener is told only when the record actually changed since it was last told, so a client’s own writes do not come back to it as news.

string

() => void

() => void

StateStorage.subscribe