lexer-state
Version:
Lightweight state machine library to define and manage state transition declaratively
23 lines (22 loc) • 1.04 kB
TypeScript
/// <reference types="react" />
import { IMachine } from '../machine';
export declare const useLexerStateBase: <Events, T extends IMachine<any, any, any> = any>(machine: T) => {
currentState: string;
dispatchEvent(e: Events[keyof Events]): void;
};
export interface ILexerMachineState<IState, IEvent> {
currentState?: IState;
dispatchEvent?: (e: IEvent[keyof IEvent]) => void;
}
export type ILexerStateContext<IState = any, IEvent = any> = [
ILexerMachineState<IState, IEvent> | undefined,
React.Dispatch<React.SetStateAction<ILexerMachineState<IState, IEvent> | undefined>>
];
export declare const LexerStateProviders: <Events = any, States = any, T extends IMachine<any, any, any> = any>({ children, machines, }: {
children?: React.ReactNode;
machines: T[];
}) => import("react/jsx-runtime").JSX.Element;
export declare const useLexerStates: <Events, T extends IMachine<any, any, any> = any, States = any>(machine: T) => {
currentState: States;
dispatchEvent: (e: Events[keyof Events]) => void;
};