Last active
February 17, 2020 18:26
-
-
Save frehner/7288066305b0421b24d313cfc1493c81 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 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