OwnedState
interfaceA writable handle to state your own mod declared. Returned by `ctx.state(declaration)` when you pass the value you built with state. This is the only writable state handle: pass a built-in name instead and you get a plain read-only State.
Import
import { OwnedState } from '@modular/sdk/editor';Members11
- accessScope
HostScopeThe scope this handle reads through: root, workspace, editor, and so on.
- capturedAt
stringWhen the current value was committed, as an ISO timestamp.
- descriptor
StateDescriptorTitle, owner, schema, scope, and sensitivity as the host sees them.
- id
string & $brand<'HostStateId'>Host-wide identifier, which for mod state includes the mod id.
- kind
'state'- previous
StateVersion<TValue> | nullThe value before the most recent write, or `null` if there was none.
- revision
numberCounter that increases on every committed write.
- value
TValueCurrent value. Reading it inside a reactive body subscribes to it.
- getSnapshot
() => StateSnapshot<TValue>Read value, revision, and previous version together, without tracking.
- set
(value: TValue, options?: StateSetOptions) => Promise<void>Write a new value and wait for the host to commit it. The value is validated against the declaration's type first, so a write that does not match rejects instead of storing bad data.
- subscribe
(listener: (snapshot: StateSnapshot<TValue>) => void) => () => voidCall `listener` on every write. Call the returned function to stop.
Notes
- category
- State