Skip to content

Instantly share code, notes, and snippets.

@kylewelsby
Created December 30, 2020 19:09
Show Gist options
  • Save kylewelsby/a13207a264fe9eccbc4d3527b7a621d2 to your computer and use it in GitHub Desktop.
Save kylewelsby/a13207a264fe9eccbc4d3527b7a621d2 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const countryMachine = Machine({
id: 'countrySwitcher',
initial: 'idle',
context: {
countryCode: 'en-US'
},
states: {
idle: {
on: {
SWITCH_COUNTRY: 'switching'
}
},
switching: {
on: {
SWITCH_COUNTRY: {
target: 'switching',
actions: assign({
countryCode: (context, event) => event.countryCode
})
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment