Askr documentation
Generated API snapshot

@askrjs/askr/foundations/state

Exports from the declarations published in @askrjs/askr. Signatures reflect the published artifact.

Exports

This entrypoint publishes 5 exports. Use the anchored symbol rows for direct links. Type-only exports are labeled separately from runtime values.

controllableStatetype

controllableState: <T>(options: { value: T | undefined; defaultValue: T; onChange?: (next: T) => void; }) => ControllableState<T>

controllableState Hook-like primitive that mirrors `state()` semantics while supporting controlled/uncontrolled behavior.

ControllableStatetype

ControllableState: State<T> & {
  isControlled: boolean;
}

A {@link State} accessor that also reports whether it is controlled.

isControlledtype

isControlled: <T>(value: T | undefined) => value is T

Whether `value` represents controlled mode (not `undefined`).

makeControllabletype

makeControllable: <T>(options: { value: T | undefined; defaultValue: T; onChange?: (next: T) => void; setInternal?: (next: T) => void; }) => { set: (next: T) => void; isControlled: boolean; }

Build a `set` function that calls `onChange` in controlled mode, or updates internal state and then calls `onChange` in uncontrolled mode.

resolveControllabletype

resolveControllable: <T>(value: T | undefined, defaultValue: T) => { value: T; isControlled: boolean; }

Resolve the effective value and controlled-ness for a controllable prop.