Last active
August 17, 2020 15:34
-
-
Save bholmesdev/da1509bc3111200ab2467882180554aa to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const configureMachine = Machine({ | |
id: 'configure', | |
initial: 'idle', | |
context: { | |
}, | |
states: { | |
idle: { | |
type: 'parallel', | |
states: { | |
form: { | |
initial: 'isIncomplete', | |
states: { | |
isComplete: { | |
on: { | |
SUBMIT: '#submitting', | |
ERRORS_FOUND: 'isIncomplete' | |
} | |
}, | |
isIncomplete: { | |
on: { | |
SUBMIT: { | |
actions: ['focusErrors'] | |
}, | |
ERRORS_CLEARED: 'isComplete' | |
} | |
} | |
} | |
}, | |
rockLobster: { | |
initial: 'isOff', | |
states: { | |
isOn: { | |
on: { | |
TOGGLE_ROCK_LOBSTER: { | |
target: 'isOff', | |
actions: ['scrollUp', 'removeFadeEffect'] | |
} | |
} | |
}, | |
isOff: { | |
on: { | |
TOGGLE_ROCK_LOBSTER: { | |
target: 'isOn', | |
actions: ['scrollDown', 'addFadeEffect'] | |
} | |
} | |
} | |
} | |
} | |
}, | |
}, | |
submitting: { | |
id: 'submitting', | |
invoke: { | |
src: 'addToCart', | |
onDone: 'submitted', | |
onError: 'idle.form.isComplete' | |
} | |
}, | |
submitted: { | |
type: 'final' | |
} | |
} | |
}, | |
{ | |
rockLobsterOn: (context) => context.rockLobsterToggled, | |
rockLobsterOff: (context) => !context.rockLobsterToggled | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment