Skip to content

Instantly share code, notes, and snippets.

@amogower
Created January 19, 2021 19:06
Show Gist options
  • Select an option

  • Save amogower/ad4bea1cd188395649166cb472295629 to your computer and use it in GitHub Desktop.

Select an option

Save amogower/ad4bea1cd188395649166cb472295629 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const singleMachine = Machine({
id: 'single',
initial: 'winOnly',
context: {
stake: '',
},
states: {
winOnly: {
id: 'winOnly',
initial: 'idle',
states: {
idle: {
on: {
FOCUS_STAKE: 'changingStake',
TOGGLE_EACH_WAY: '#eachWay',
TOGGLE_SELECTIONS: 'expanded',
},
},
changingStake: {
on: {
PLACE_BET: {
actions: sendParent('PLACE_BET'),
},
TOGGLE_EACH_WAY: '#eachWay',
TOGGLE_SELECTIONS: 'expanded',
},
},
expanded: {
initial: 'idle',
states: {
idle: {
on: {
FOCUS_STAKE: 'changingStake',
TOGGLE_EACH_WAY: '#eachWay.expanded',
TOGGLE_SELECTIONS: '#winOnly',
},
},
changingStake: {
on: {
PLACE_BET: {
actions: sendParent('PLACE_BET'),
},
TOGGLE_EACH_WAY: '#eachWay.expanded',
TOGGLE_SELECTIONS: '#winOnly',
},
},
},
},
},
},
eachWay: {
id: 'eachWay',
initial: 'idle',
states: {
idle: {
on: {
FOCUS_STAKE: 'changingStake',
TOGGLE_EACH_WAY: '#winOnly',
TOGGLE_SELECTIONS: 'expanded',
},
},
changingStake: {
on: {
PLACE_BET: {
actions: sendParent('PLACE_BET'),
},
TOGGLE_EACH_WAY: '#winOnly',
TOGGLE_SELECTIONS: 'expanded',
},
},
expanded: {
initial: 'idle',
states: {
idle: {
on: {
FOCUS_STAKE: 'changingStake',
TOGGLE_EACH_WAY: '#winOnly.expanded',
TOGGLE_SELECTIONS: '#eachWay',
},
},
changingStake: {
on: {
PLACE_BET: {
actions: sendParent('PLACE_BET'),
},
TOGGLE_EACH_WAY: '#winOnly.expanded',
TOGGLE_SELECTIONS: '#eachWay',
},
},
},
},
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment