EnvironmentSessionState

A scoped view over the session store: one environment's state, or one scene's.

@internote/canvas-sdkInterface
On this page
import { EnvironmentSessionState } from '@internote/canvas-sdk';

What ctx.storage.session is. In a surface, read it through useEnvironmentSession, which subscribes and re-renders.

#Fields

clearRequired
Deletes the state and notifies subscribers.
void
getRequired
Returns the current state, or undefined before anything was written.
S | undefined
setRequired
Replaces the state and notifies subscribers.
void
subscribeRequired
Calls the listener after every write to this state, and returns the unsubscribe.
() => void
updateRequired
Replaces the state with what the updater returns from the previous one, and notifies subscribers.
void

#Example

const state = (ctx.storage.session.get() as GreetingState | undefined) ?? initialState();
ctx.storage.session.update((previous) => ({ ...(previous as GreetingState), waves: state.waves + 1 }));

Declared in packages/canvas-sdk/src/storage/session.ts:87.

Last updated