Interface: StateEngine\<T\>
@roomful/core / StateEngine
Interface: StateEngine<T>
Section titled “Interface: StateEngine<T>”Defined in: packages/core/src/types.ts:1089
Exposes shared-state operations for a room.
Type Parameters
Section titled “Type Parameters”T
The shared state value type.
Methods
Section titled “Methods”get():
T
Defined in: packages/core/src/types.ts:1095
Reads the latest shared state value.
Returns
Section titled “Returns”T
The current shared state value.
patch()
Section titled “patch()”patch(
partial):void
Defined in: packages/core/src/types.ts:1111
Partially updates a shared object state.
Parameters
Section titled “Parameters”partial
Section titled “partial”Partial<T>
The partial state value to merge.
Returns
Section titled “Returns”void
Nothing.
reset()
Section titled “reset()”reset():
void
Defined in: packages/core/src/types.ts:1133
Restores the shared state to its initial value.
Returns
Section titled “Returns”void
Nothing.
set(
value):void
Defined in: packages/core/src/types.ts:1103
Replaces the shared state value.
Parameters
Section titled “Parameters”T
The next shared state value.
Returns
Section titled “Returns”void
Nothing.
subscribe()
Section titled “subscribe()”subscribe(
cb):Unsubscribe
Defined in: packages/core/src/types.ts:1119
Subscribes to shared-state changes.
Parameters
Section titled “Parameters”(value, meta) => void
The callback invoked with the latest value and metadata.
Returns
Section titled “Returns”A function that removes the listener.
undo()
Section titled “undo()”undo():
void
Defined in: packages/core/src/types.ts:1126
Reverts the most recent shared-state change when possible.
Returns
Section titled “Returns”void
Nothing.