state-switch
Version:
State Switch is a Change Monitor/Guarder for Async Actions.
73 lines • 1.26 kB
JavaScript
const inactive = {
// entry : 'onEntry',
// exit : 'onExit',
on: {
START: 'starting',
},
};
const starting = {
invoke: {
onDone: 'active',
onError: 'canceled',
src: 'start',
},
on: {
CANCEL: 'inactive',
},
};
const active = {
// entry : 'onEntry',
// exit : 'onExit',
on: {
RESET: 'resetting',
STOP: 'stopping',
},
};
const stopping = {
invoke: {
onDone: 'inactive',
onError: 'canceled',
src: 'stop',
},
on: {
CANCEL: 'inactive',
},
};
const resetting = {
invoke: {
onDone: 'active',
onError: 'canceled',
src: 'reset',
},
on: {
CANCEL: 'inactive',
},
};
const canceled = {
// entry : 'onEntry',
// exit : 'onExit',
on: {
RESET: 'resetting',
START: 'starting',
STOP: 'stopping',
},
};
const states = {
active,
canceled,
inactive,
resetting,
starting,
stopping,
};
const initialContext = () => ({
counter: 0,
});
const config = {
context: initialContext(),
id: 'ServiceCtlMachine',
initial: 'inactive',
states,
};
export { config };
//# sourceMappingURL=machine-config.js.map