Skip to content

Instantly share code, notes, and snippets.

@diestrin
Last active April 12, 2021 21:51
Show Gist options
  • Save diestrin/80d4397deee58f893a45512a9050d4b9 to your computer and use it in GitHub Desktop.
Save diestrin/80d4397deee58f893a45512a9050d4b9 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({
context: {},
initial: 'ordered',
states: {
ordered: {
on: {
DO_LOAD: {
target: 'loading'
}
}
},
ready: {
on: {
DO_LOAD: {
target: 'loading'
}
}
},
cancelled: {
on: {
DO_LOAD: {
target: 'loading'
}
}
},
loading: {
on: {
FINISH_LOAD: {
target: 'loaded'
},
DO_CANCEL: {
target: 'cancelled'
}
}
},
loaded: {
on: {
DO_DISPENSE: {
target: 'dispensing'
},
DO_VERIFY: {
target: 'verified'
},
DO_UNDO: {
target: 'ready'
},
DO_REMOVE: {
target: 'removing'
},
DO_RECLAIM: {
target: 'reclaim'
},
VERIFY_LOCKED_DOWN: {
target: 'lockeddown'
}
}
},
removing: {
on: {
FINISH_REMOVING: {
target: 'removed'
}
}
},
removed: {
type: 'final'
},
verified: {
on: {
DO_DISPENSE: {
target: 'dispensing'
}
}
},
dispensing: {
on: {
FINISH_DISPENSE: {
target: 'dispensed'
},
DO_UNDO: {
target: 'loaded',
}
}
},
dispensed: {
type: 'final'
},
lockeddown: {
on: {
DO_RECLAIM: {
target: 'reclaim'
}
}
},
reclaim: {
on: {
FINISH_RECLAIM: {
target: 'reclaimed'
}
}
},
reclaimed: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment