UNPKG

lexer-state

Version:

Lightweight state machine library to define and manage state transition declaratively

16 lines 499 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useLexerState = void 0; const react_1 = require("react"); // Todo: use context const useLexerState = (machine) => { const [currentState, setCurrentState] = (0, react_1.useState)(machine.currentState); return { currentState, dispatchEvent(e) { setCurrentState(machine.next(e)); }, }; }; exports.useLexerState = useLexerState; //# sourceMappingURL=useLexerState.js.map