Skip to content

Instantly share code, notes, and snippets.

@HipsterBrown
Created January 14, 2021 16:48
Show Gist options
  • Save HipsterBrown/b6bdf47a891d4b177d32714e070291c2 to your computer and use it in GitHub Desktop.
Save HipsterBrown/b6bdf47a891d4b177d32714e070291c2 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: 'flow',
initial: 'init',
context: {
values: {}
},
states: {
init: {
invoke: {
src: 'getValuesFromSessionStorage',
onDone: {
target: 'step1',
actions: 'setValuesInContext'
},
onError: 'step1'
}
},
step1: {
on: {
NEXT: {
target: 'step2',
actions: ['setValuesInContext', 'syncValuesToSessionStorage']
}
}
},
step2: {
type: 'final'
}
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment