import { Action } from './action'; import { Box, Mutation } from './box'; import { Selector } from './selector'; import { Signal } from './signal'; import { AmosObject } from './utils'; /** * the state snapshot in store * * @stable */ export declare type Snapshot = Record; /** * dispatchable things * * @stable */ export declare type Dispatchable = Mutation | Action | Signal; /** * base amos signature, this is used for someone want to change the signature of useDispatch() * * @stable */ export interface AmosDispatch extends AmosObject<'store.dispatch'> { (task: Dispatchable): R; (tasks: readonly [Dispatchable]): [R1]; (tasks: readonly [Dispatchable, Dispatchable]): [R1, R2]; (tasks: readonly [Dispatchable, Dispatchable, Dispatchable]): [ R1, R2, R3 ]; (tasks: readonly [Dispatchable, Dispatchable, Dispatchable, Dispatchable]): [R1, R2, R3, R4]; (tasks: readonly [ Dispatchable, Dispatchable, Dispatchable, Dispatchable, Dispatchable ]): [R1, R2, R3, R4, R5]; (tasks: readonly [ Dispatchable, Dispatchable, Dispatchable, Dispatchable, Dispatchable, Dispatchable ]): [R1, R2, R3, R4, R5, R6]; (tasks: readonly [ Dispatchable, Dispatchable, Dispatchable, Dispatchable, Dispatchable, Dispatchable, Dispatchable ]): [R1, R2, R3, R4, R5, R6, R7]; (tasks: readonly [ Dispatchable, Dispatchable, Dispatchable, Dispatchable, Dispatchable, Dispatchable, Dispatchable, Dispatchable ]): [R1, R2, R3, R4, R5, R6, R7, R8]; (tasks: readonly [ Dispatchable, Dispatchable, Dispatchable, Dispatchable, Dispatchable, Dispatchable, Dispatchable, Dispatchable, Dispatchable ]): [R1, R2, R3, R4, R5, R6, R7, R8, R9]; (tasks: readonly Dispatchable[]): R[]; } export interface Dispatch extends AmosDispatch { } /** * selectable things * * @stable */ export declare type Selectable = Box | Selector; /** * select * * @stable */ export interface Select extends AmosObject<'store.select'> { (selectable: Selectable, snapshot?: Snapshot): R; } /** * Store * * @stable */ export interface Store { /** * get the state snapshot of the store. * * Please note that any mutation of the snapshot is silent. */ snapshot: () => Snapshot; /** * dispatch one or more dispatchable things. */ dispatch: Dispatch; /** * subscribe the mutations * @param fn */ subscribe: (fn: (updatedState: Snapshot) => void) => () => void; /** * select a selectable thing */ select: Select; } export declare type StoreEnhancer = (store: Store) => Store; /** * create a store * @param preloadedState * @param enhancers * * @stable */ export declare function createStore(preloadedState?: Snapshot, ...enhancers: StoreEnhancer[]): Store;