Skip to content

Instantly share code, notes, and snippets.

@jinnkhan88
Created June 6, 2021 20:05
Show Gist options
  • Save jinnkhan88/4835468fdac4350b3bf0184948ea3bd4 to your computer and use it in GitHub Desktop.
Save jinnkhan88/4835468fdac4350b3bf0184948ea3bd4 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const childMachine = Machine({
id: 'child',
initial: 'step1',
states: {
step1: {
on: { STEP: 'step2' },
},
step2: {
on: { STEP: 'step3' },
},
step3: {
type: 'final',
},
},
})
const parentMachine = Machine({
id: 'parent',
initial: 'idle',
states: {
idle: {
on: { ACTIVATE: 'active' },
},
active: {
// invoke another machine
invoke:{
id:'child',
src:childMachine,
onDone:'done'
},
on:{
STEP:{
actions:send('STEP',{
to:'child'
})
}
}
},
done: {},
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment