lexer-state
Version:
Lightweight state machine library to define and manage state transition declaratively
24 lines (23 loc) • 1.06 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 LexerStateProvider: <Events = any, States = any, T extends IMachine<any, any, any> = any>({ children, machines, machine, }: {
children?: React.ReactNode;
machines?: T[];
machine?: T;
}) => import("react/jsx-runtime").JSX.Element;
export declare const useLexerState: <Events, States = any, T extends IMachine<any, any, any> = any>(machine: T) => {
currentState: States;
dispatchEvent: (e: Events[keyof Events]) => void;
};