Created
December 30, 2020 19:09
-
-
Save kylewelsby/a13207a264fe9eccbc4d3527b7a621d2 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
// 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