Last active
October 16, 2019 13:42
-
-
Save janmonschke/ffab8f08ae42a4b0e76ed3fefa8f479d to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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) | |
function wait(ms) { | |
return new Promise( | |
(resolve) => setTimeout(resolve, ms) | |
); | |
} | |
const fetchMachine = Machine({ | |
id: 'mastering', | |
initial: 'onboarding', | |
context: { selectedPresets: [] }, | |
states: { | |
onboarding: { | |
on: { | |
SKIP: 'selectPresets', | |
DONE: 'selectPresets' | |
} | |
}, | |
selectPresets: { | |
on: { | |
PRESETS_SELECTED: { | |
target: 'fetchingPreviews' | |
} | |
} | |
}, | |
fetchingPreviews: { | |
invoke: { | |
id: 'fetchPreviews', | |
src: () => wait(3000), | |
onDone: 'previews' | |
} | |
}, | |
previews: { | |
on: { | |
PRESET_SELECTED: 'done', | |
CHANGE_PRESETS: "selectPresets" | |
} | |
}, | |
done: { | |
type: 'final' | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment