UNPKG

@bemedev/app-react

Version:
24 lines (21 loc) 925 B
import { interpret as interpret$1, getByKey } from '@bemedev/app-ts'; import { useSelector } from './useSelector.js'; import { defaultCompare } from './utils/compare.js'; import 'dequal'; import { identity } from './utils/identity.js'; import { reFunction } from './utils/reFunction.js'; const interpret = (machine, config) => { const service = interpret$1(machine, config); const start = reFunction(service, 'start'); const stop = reFunction(service, 'stop'); const send = reFunction(service, 'send'); const addOptions = reFunction(service, 'addOptions'); const selector = (identity); const useState = (key, compare = defaultCompare) => { const out = useSelector(service, state => (!key ? state : getByKey(state, key)), compare); return out; }; return { start, stop, send, selector, useState, addOptions }; }; export { interpret }; //# sourceMappingURL=interpret.js.map