Skip to content

Instantly share code, notes, and snippets.

@chrisdhanaraj
Created July 15, 2019 23:54
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 chrisdhanaraj/4f5df7f49036e694cab24cd8494a73e5 to your computer and use it in GitHub Desktop.
Save chrisdhanaraj/4f5df7f49036e694cab24cd8494a73e5 to your computer and use it in GitHub Desktop.
Generated by [XState Viz](https://xstate.js.org/viz)
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
// const pingMachine = Machine({
// id: 'ping',
// initial: 'active',
// states: {
// active: {
// invoke: {
// id: 'pong',
// src: pongMachine
// }
// // Sends 'PING' event to child machine with ID 'pong'
// entry: send('PING', { to: 'pong' }),
// on: {
// PONG: {
// actions: send('PING', {
// to: 'pong',
// delay: 1000
// })
// }
// }
// }
// }
// });
// Invoked child machine
const pongMachine = Machine({
id: 'pong',
initial: 'active',
states: {
active: {
on: {
PING: {
// Sends 'PONG' event to parent machine
actions: sendParent('PONG', {
delay: 1000
})
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment