Moore
finite-state machine whose output values are determined only by its current state
Currently has the following features implemented:
Below a configuration example:
every state has an on property defined, which can hold listeners and an output function.
listeners are not fired in Moore machines.
the output function is a curried function which returns a Promise.
only the initial state needs to be defined at firsthand.
states can be added after the machine has been started.
import { MooreStateMachine } from 'status-machina'
const model = {
addTodo: {
listTodos: {},
},
changeTodo: {
listTodos: {},
},
listTodos: {
addTodo: {},
changeTodo: {},
listTodos: {},
}
}
// create a new moore state machine
// with states and initial state
export const store = new MooreStateMachine(states, 'listTodos', {});
Last updated
Was this helpful?