@logixjs/core
    Preparing search index...

    Interface ModuleRuntime<S, A>

    The runtime interface of a Module (similar to "Store as Context" in docs), exposing read/write, subscription, and dispatch capabilities to Logic / Flow.

    interface ModuleRuntime<S, A> {
        actions$: Stream<A>;
        actionsWithMeta$: Stream<StateChangeWithMeta<A>>;
        changes: <V>(selector: (s: S) => V) => Stream<V>;
        changesReadQueryWithMeta: <V>(
            readQuery: ReadQueryInput<S, V>,
        ) => Stream<StateChangeWithMeta<V>>;
        changesWithMeta: <V>(
            selector: (s: S) => V,
        ) => Stream<StateChangeWithMeta<V>>;
        dispatch: (action: A) => Effect<void>;
        dispatchBatch: (actions: readonly A[]) => Effect<void>;
        dispatchLowPriority: (action: A) => Effect<void>;
        getState: Effect<S>;
        instanceId: string;
        lifecycleStatus?: Effect<LifecycleStatus, never, never>;
        moduleId: string;
        ref: <V = S>(selector?: (s: S) => V) => SubscriptionRef<V>;
        setState: (next: S) => Effect<void>;
    }

    Type Parameters

    • S
    • A
    Index

    Properties

    actions$: Stream<A>
    actionsWithMeta$: Stream<StateChangeWithMeta<A>>
    changes: <V>(selector: (s: S) => V) => Stream<V>

    Subscribe to changes of a selector. Note: an implementation may be based on state$ + distinctUntilChanged.

    changesReadQueryWithMeta: <V>(
        readQuery: ReadQueryInput<S, V>,
    ) => Stream<StateChangeWithMeta<V>>

    Subscribe to ReadQuery (SelectorSpec) changes, including commit meta of the current commit.

    • static lane: driven by SelectorGraph (precise recompute + cache + precise notifications)
    • dynamic lane: may fall back to per-commit recompute (legacy)
    changesWithMeta: <V>(selector: (s: S) => V) => Stream<StateChangeWithMeta<V>>

    Subscribe to changes of a selector, including commit meta of the current commit (commitMode/priority, etc.).

    dispatch: (action: A) => Effect<void>
    dispatchBatch: (actions: readonly A[]) => Effect<void>
    dispatchLowPriority: (action: A) => Effect<void>
    getState: Effect<S>
    instanceId: string

    Stable instance anchor (single source of truth), aligned with 009/011/016.

    • Must be injectable/derivable; never default to randomness/time.
    • Do not expose a "second anchor" field to avoid multiple sources of truth.
    lifecycleStatus?: Effect<LifecycleStatus, never, never>

    Lifecycle status (serializable and consumable by Devtools/Sandbox).

    • initProgress is updated during initRequired.
    • initOutcome.failure is populated when initialization fails.
    moduleId: string

    Associated module identifier:

    • Injected by ModuleRuntime.make from options.moduleId at construction time.
    • Primarily used by Devtools / debugging to align runtime instances with module-level information.
    ref: <V = S>(selector?: (s: S) => V) => SubscriptionRef<V>

    Provide a SubscriptionRef for long-running / fine-grained logic to borrow state directly. The current implementation only exposes a ref for the whole state; selector views are up to the caller to wrap.

    setState: (next: S) => Effect<void>