Skip to content

Instantly share code, notes, and snippets.

@frehner
Created February 11, 2020 18:16
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/2740527eeb35dd946e6b711f1c76f7e7 to your computer and use it in GitHub Desktop.
Save frehner/2740527eeb35dd946e6b711f1c76f7e7 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
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