Last active
August 26, 2020 15:13
-
-
Save davidkpiano/04c57c4a3474e12a373564d4303873ff to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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