Created
February 11, 2020 18:16
-
-
Save frehner/2740527eeb35dd946e6b711f1c76f7e7 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 timerMachine = Machine({ | |
id: 'timer', | |
context: { | |
duration: 1000, | |
otherThing: 'hey' | |
}, | |
initial: 'test', | |
states: { | |
test: { | |
entry: context => console.log('context:', context) | |
} | |
} | |
}); | |
const parentMachine = Machine({ | |
id: 'parent', | |
initial: 'active', | |
context: { | |
customDuration: 3000 | |
}, | |
states: { | |
active: { | |
invoke: { | |
id: 'timer', | |
src: timerMachine, | |
data: { | |
duration: (context, event) => context.customDuration | |
} | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment