Created
January 19, 2021 19:06
-
-
Save amogower/0adbdd63036c2ce534bd63cd89a6aca6 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
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