Skip to content

Instantly share code, notes, and snippets.

@bholmesdev
Last active August 21, 2020 17:09
Show Gist options
  • Save bholmesdev/a162b195f8823891ca5cf97fcc01269b to your computer and use it in GitHub Desktop.
Save bholmesdev/a162b195f8823891ca5cf97fcc01269b 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 configureMachine = Machine({
id: 'configure',
initial: 'idle',
context: {
errorType: 'incomplete',
rockLobsterToggled: false
},
states: {
idle: {
initial: 'incomplete',
states: {
incomplete: {
on: {
SUBMIT: {
actions: ['focusFormElements']
}
}
},
complete: {
on: {
SUBMIT: '#submitting'
}
}
},
on: {
ERRORS_FOUND: '.incomplete',
ERRORS_CLEARED: '.complete',
TOGGLE_ROCK_LOBSTER: {
actions: [
assign({
rockLobsterToggled: (context) => !context.rockLobsterToggled
}),
'setScrollPosition',
'setFadeEffect']
},
}
},
submitting: {
id: 'submitting',
invoke: {
src: 'addToCart',
onDone: 'submitted',
onError: 'idle.complete'
},
},
submitted: {
type: 'final'
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment