UNPKG

@renewx/core

Version:

Lightweight state management library with validation support

18 lines (17 loc) 1.15 kB
import type { ReadOnlyStore } from "../types/read-only-store"; import type { Config } from "../types/config"; import type { StoreID } from "../types/id"; import type { Freeze } from "../types/freeze"; import type { ActionInfo } from "../types/action"; export type Process = (states: any[]) => 1 | undefined; export declare const allStates: any[]; export declare const setNewState: <State>(primaryId: StoreID, newState: Freeze<State>, info?: ActionInfo) => void; export declare const getProcess: (id: StoreID) => Process | undefined; /** * Defines a new state for a store based on dependencies to other stores. * @param store - The store for which a new state is being calculated. * @param dependsOn - An array of StoreIDs representing the stores this store depends on. * @param getNewState - A function that returns a new state. The order of states is the same as the array of stores it dependsOn. * @param config - Configuration options for the state addition. */ export declare const addProcessNewState: <ToState>(store: ReadOnlyStore<ToState>, dependsOn: StoreID[], getNewState: (states: any[]) => Freeze<ToState>, config: Config) => void;