@cran/vue.use
Version:
Cranberry Vue Use Utilities
16 lines (15 loc) • 507 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.useMachine = void 0;
const runtime_dom_1 = require("@vue/runtime-dom");
function useMachine(states, initial) {
const state = (0, runtime_dom_1.ref)(initial);
function next(event) {
const nextState = (states[state.value] || {})[event];
if (nextState && nextState !== state.value) {
state.value = nextState;
}
}
return { state, next, };
}
exports.useMachine = useMachine;