@s-libs/signal-store
    Preparing search index...

    Class DetachedStore<T>

    A store object that is NOT backed by signals. This is a utility class to efficiently manage deeply nested immutable state with the same API as RootStore. This is useful when reusing functions that can work with stores used in your templates, but when you only need the result without directly rendering it, e.g. in unit tests.

    Type Parameters

    • T

    Hierarchy

    • AbstractStore<T>
      • DetachedStore
    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    assign: IfCouldBe<
        T,
        any[]
        | Nil
        | Primitive,
        never,
        (value: Partial<T>) => void,
    > = ...

    Assigns the given values to the state of this store object. The resulting state will be like Object.assign(store.state, value).

    state: T

    Accessors

    Methods

    • Runs func on a shallow clone of the state, replacing the state with the clone. The first argument to func will be the cloned state, followed by the arguments in args.

      WARNING: You SHOULD NOT use a function that will mutate nested objects within the state.

      Type Parameters

      • A extends any[]

      Parameters

      • func: (state: T, ...args: A) => void
      • ...args: A

      Returns void

    • Runs func on the state and replaces it with the return value. The first argument to func will be the state, followed by the arguments in args.

      WARNING: You SHOULD NOT use a function that will mutate the state.

      Type Parameters

      • A extends any[]

      Parameters

      • func: (state: T, ...args: A) => T
      • ...args: A

      Returns void