Skip to content

Instantly share code, notes, and snippets.

@andrewgordstewart
Created November 20, 2019 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewgordstewart/c94c8d1c0cb8a716f3cb22e58f68f381 to your computer and use it in GitHub Desktop.
Save andrewgordstewart/c94c8d1c0cb8a716f3cb22e58f68f381 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const minuteMachine = Machine({
id: 'timer',
initial: 'active',
states: {
active: {
after: {
5000: 'finished'
}
},
finished: { type: 'final', entry: sendParent('TIMES_UP') }
}
});
const alarmClock = Machine({
id: 'parent',
type: 'parallel',
states: {
minutes: {
initial: 'run',
states: {
run: {
invoke: { src: minuteMachine }
}
}
},
alarm: {
initial: 'pending',
states: {
pending: { on: { TIMES_UP: 'timesUp' } },
timesUp: { type: 'final' }
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment