UNPKG

@cran/vue.use

Version:

Cranberry Vue Use Utilities

12 lines (11 loc) 345 B
import { ref } from "@vue/runtime-dom"; export function useMachine(states, initial) { const state = ref(initial); function next(event) { const nextState = (states[state.value] || {})[event]; if (nextState && nextState !== state.value) { state.value = nextState; } } return { state, next, }; }