UNPKG

@state-management/state-machine-react

Version:

React wrapper for simple-state-machine, provides fromState and useDispatcher hooks and unit test fixtures

16 lines (15 loc) 562 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const react_1 = require("react"); const simple_state_machine_1 = require("@state-management/simple-state-machine"); /** * Custom hook for dispatching commands in the state machine. * @returns A function to dispatch commands to the state machine. */ function useDispatcher() { const dispatch = (0, react_1.useCallback)((command) => { simple_state_machine_1.StateMachine.getInstance().dispatch(command); }, []); return dispatch; } exports.default = useDispatcher;