Skip to content

Instantly share code, notes, and snippets.

@mwagz
Last active October 29, 2020 14:12
Show Gist options
  • Save mwagz/5ad00cd3ad8d4dfed736c4a2b9847c1f to your computer and use it in GitHub Desktop.
Save mwagz/5ad00cd3ad8d4dfed736c4a2b9847c1f to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine({
id: 'actions-builder',
initial: 'choose',
states: {
choose: {
always: [
{
target: 'idle',
cond: 'hasActivities',
},
{ target: 'selecting' },
],
},
idle: {
entry: 'setIdleState',
on: {
BUILD: 'selecting',
EDIT: {
target: 'editing',
actions: 'doEditActivity',
},
DELETE: {
target: 'choose',
actions: 'doDeleteActivity',
},
},
},
selecting: {
entry: [
'getActivityRegistries',
'setSelectingState'
],
on: {
SET_ACTIVITIES: {
actions: 'doSetActivities',
},
SELECTED: 'building',
CANCEL: 'idle',
},
},
building: {
entry: 'setBuildingState',
on: {
SAVE: {
target: 'idle',
actions: 'doSaveActivities',
},
CANCEL: 'idle',
},
},
editing: {
entry: 'setEditState',
on: {
UPDATE: {
target: 'idle',
actions: 'doUpdateActivities',
},
CANCEL: 'idle',
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment