← All packages

API reference

@searsuite/sear-domain-state

Typed data ownership, field projection, and state registry contracts.

1 exportsderived from source

Concept 1

Know which state can change

Sheet content, formatting, formulas, selection, and dimensions have separate owners. A feature registers the state it owns and publishes typed reads or operations for that state. SearState and the domain contracts give the runtime a way to compose those contributions without turning the base cell value into a universal feature object.

Document state is durable editor or Workbook content. Session state is local state captured for remounting, such as a viewport. Derived state is computed from other values, such as formula results or render projections. Host state includes transport and product UI. A consumer should choose the corresponding query, observation, or export contract rather than assuming every visible value is stored in the document.

Concept 2

Read a projection without taking ownership

DataEngine fields and visual readers project owner state for consumers. The owner registers its field key and typed reader; a renderer or host consumes that projection. A missing sparse entry means the current default applies, so merely reading or painting a cell does not create persisted state.

Use when: defining a new state-owning feature or reading its value in another layer. Mutate through the owning feature's command, and use its projection for reads. Portable OT operations describe committed changes, while export codecs describe durable file data; neither is inferred from a visual projection.

classSearStatesource ↗
class SearState<T>

Observable base contract for domain state containers.

State implementations expose cell-like reads, OT dispatch, and change notifications while owning their concrete storage strategy.

constructorconstructor
SearState<T>(): SearState<T>
propertyname
name: string

Stable state name used when registering state in plugin/core maps.

methodaddListener
addListener(listener: Listener): void

Registers a listener for future state changes.

listener: Listener

Callback invoked after notifyListeners().

methoddispatch
dispatch(operations: StateOperation[]): this

Applies OT operations to this state object.

ReturnsThe current state instance for chaining.

operations: StateOperation[]

Operations owned by the concrete state implementation.

methodgetItem
getItem(row: string | number, col: string | number): T | null

Reads one value from the state using a row/column style address.

ReturnsStored value, null when no value is present.

row: string | number

Row or first path coordinate.

col: string | number

Column or second path coordinate.

methodremoveListener
removeListener(listener: Listener): void

Removes a previously registered listener.

listener: Listener

Callback to detach from this state object.