Skip to content

Instantly share code, notes, and snippets.

@frehner
Last active February 17, 2020 18:26
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 frehner/7288066305b0421b24d313cfc1493c81 to your computer and use it in GitHub Desktop.
Save frehner/7288066305b0421b24d313cfc1493c81 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const childMachine = Machine({
id: "child",
initial: "waiting",
states: {
waiting: {
on: {
OUTER: {
actions: (ctx, act) => console.log('outer'),
},
MAPPED: {
actions: (ctx, act) => console.log('mapped')
}
}
}
}
})
const fetchMachine = Machine({
id: 'fetch',
initial: 'idle',
states: {
idle: {
invoke: {
src: childMachine,
id: "childMachine",
},
on: {
OUTER: {
actions: [sendToChild]
}
}
},
}
});
function sendToChild(ctx, evt) {
console.log('in sendToChild')
send("MAPPED", {to: 'childMachine'})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment