Skip to content

Instantly share code, notes, and snippets.

@amogower
Created January 19, 2021 19:06
Show Gist options
  • Save amogower/0adbdd63036c2ce534bd63cd89a6aca6 to your computer and use it in GitHub Desktop.
Save amogower/0adbdd63036c2ce534bd63cd89a6aca6 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const selectionMachine = Machine({
id: 'selection',
context: {
stake: '',
},
initial: 'active',
states: {
active: {
initial: 'idle',
states: {
idle: {
on: {
FOCUS_STAKE: 'changingStake',
TOGGLE_ACTIVE: '#selection.inactive',
},
},
changingStake: {
on: {
CHANGE_STAKE: {
actions: 'changeStake',
},
BLUR_STAKE: 'idle',
TOGGLE_ACTIVE: '#selection.inactive',
},
},
},
},
inactive: {
initial: 'idle',
states: {
idle: {
on: {
FOCUS_STAKE: 'changingStake',
TOGGLE_ACTIVE: '#selection.active',
},
},
changingStake: {
on: {
CHANGE_STAKE: {
actions: 'changeStake',
},
BLUR_STAKE: 'idle',
TOGGLE_ACTIVE: '#selection.active',
},
},
},
},
},
}, {
actions: {
changeStake: assign({
stake: (_, evt) => evt.stake,
}),
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment