Skip to content

Instantly share code, notes, and snippets.

@davidkpiano
Last active August 26, 2020 15:13
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 davidkpiano/04c57c4a3474e12a373564d4303873ff to your computer and use it in GitHub Desktop.
Save davidkpiano/04c57c4a3474e12a373564d4303873ff to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const pongMachine = Machine({
initial: 'waiting',
states: {
waiting: {
on: {
PING: {
actions: sendParent('PONG', { delay: 1000 })
}
}
}
}
});
const pingMachine = Machine({
initial: 'active',
invoke: {
id: 'pong',
src: pongMachine
},
states: {
active: {
entry: send('PING', { to: 'pong' }),
on: {
PONG: 'ponged'
}
},
ponged: {
after: {
5000: 'active'
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment