Skip to main content

StateDeclaration

interface

One piece of state your mod owns, declared at author time. This is the declaration, not the data. You list it in `defineMod`'s `state` slot and keep the value around to pass to `ctx.state(declaration)`, which is what hands you a live OwnedState handle you can read and write.

interface StateDeclaration<TValue>

Import

import { StateDeclaration } from '@modular/sdk/state';

Members9

[runtimeContractCompilerValue]
GeneratedRuntimeContract
[runtimeContractType]
RuntimeContract<TValue>
id
string & $brand<'StateDeclarationId'>

Identifier, unique within the mod.

initial
TValue

Value used the first time this state is registered.

kind
'state-declaration'
scope
'profile' | 'workspace'

Whether the value persists per workspace or per profile.

sensitivity
'workspace' | 'private' | 'public' | 'secret'

How freely the host may share the value, defaulting to `private`.

stabilityoptional
'internal' | 'experimental' | 'stable'

Compatibility promise you are making to readers of this state.

titleoptional
string

Human-readable label shown where the host lists mod state.

Notes

category
State