Skip to content

Instantly share code, notes, and snippets.

@janmonschke
Last active October 16, 2019 13:42
Show Gist options
  • Save janmonschke/ffab8f08ae42a4b0e76ed3fefa8f479d to your computer and use it in GitHub Desktop.
Save janmonschke/ffab8f08ae42a4b0e76ed3fefa8f479d 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)
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