@zedux/machines
Version:
Simple native state machine implementation for Zedux atoms
12 lines (11 loc) • 1.12 kB
TypeScript
import { StoreEffect } from '@zedux/atoms';
import { MachineStore } from './MachineStore';
export declare type MachineHook<StateNames extends string, EventNames extends string, Context extends Record<string, any> | undefined> = (store: MachineStore<StateNames, EventNames, Context>, storeEffect: StoreEffect<MachineStateShape<StateNames, Context>, MachineStore<StateNames, EventNames, Context>>) => void;
export interface MachineStateShape<StateNames extends string = string, Context extends Record<string, any> | undefined = undefined> {
value: StateNames;
context: Context;
}
export declare type MachineStoreContextType<M extends MachineStore> = M extends MachineStore<any, any, infer C> ? C : never;
export declare type MachineStoreEventNamesType<M extends MachineStore> = M extends MachineStore<any, infer E, any> ? E : never;
export declare type MachineStoreStateType<M extends MachineStore> = M extends MachineStore<infer S, any, infer C> ? MachineStateShape<S, C> : never;
export declare type MachineStoreStateNamesType<M extends MachineStore> = M extends MachineStore<infer S, any, any> ? S : never;