Skip to content

Instantly share code, notes, and snippets.

@jeremy-green
Created September 13, 2019 11:51
Show Gist options
  • Save jeremy-green/300ab042e15405fec42e201822007821 to your computer and use it in GitHub Desktop.
Save jeremy-green/300ab042e15405fec42e201822007821 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const interval = 5000;
new Machine({
id: 'timer',
initial: 'waiting',
states: {
waiting: {
after: {
[interval]: 'loading',
},
},
loading: {
invoke: {
async src(context, event) {
return new Promise(r => setTimeout(r, 2500))
},
onDone: { target: 'waiting' },
onError: { target: 'waiting' },
},
},
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment