Skip to content

Instantly share code, notes, and snippets.

@ChrisShank
Created April 21, 2021 23:45
Show Gist options
  • Save ChrisShank/a7c11b06ad96dc31d1340439e304d76f to your computer and use it in GitHub Desktop.
Save ChrisShank/a7c11b06ad96dc31d1340439e304d76f to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine(
{
id: 'app',
initial: 'loading',
states: {
loading: {
type: 'parallel',
states: {
animation: {
initial: 'animating',
states: {
animating: {
after: {
3000: 'completed',
},
},
completed: { type: 'final' },
},
},
api: {
initial: 'fetching',
states: {
fetching: {
invoke: {
src: 'fetchFromAPI',
onDone: { target: 'completed', actions: 'assignData' },
},
},
completed: { type: 'final' },
}
},
},
onDone: 'completed',
},
completed: {},
}
},
{
services: {
fetchFromAPI: () => Promise.resolve([])
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment