Last active
January 16, 2021 21:50
-
-
Save tomByrer/9d6e5352666fe9a7011b78d7ea46f644 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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
// Master machine for radio buttons | |
const inputGroupMachine = Machine({ | |
id: 'input-group', | |
initial: 'emptied', | |
states: { | |
emptied: { | |
on: { | |
'': { | |
actions: 'loadNew', | |
target: 'pending', | |
}, | |
} | |
}, | |
pending: { | |
on: { | |
REJECT: 'failure', | |
FULFILL: 'distributing', | |
} | |
}, | |
failure: { | |
on: { | |
RETRY: 'pending', | |
} | |
}, | |
distributing: { // render indivudal items array | |
on: { | |
COMPLETE: 'selectable', | |
// REJECT: 'failure', | |
} | |
}, | |
selectable: { | |
initial: 'empty', | |
states: { | |
empty: { | |
on: { | |
FILL: 'full', | |
SKIP: '#skip-current', | |
} | |
}, | |
full: { | |
on: { | |
FILL: 'full', // EMPTY old item | |
SKIP: '#skip-current', | |
SUBMIT: 'submitting', | |
// SELECT: 'sending' | |
} | |
}, | |
submitting: { | |
on: { | |
COMPLETE: '#empty-old' | |
} | |
}, | |
} | |
}, | |
skipping: { | |
id: 'skip-current', | |
on: { | |
'': { | |
actions: 'skipCurrent', | |
target: 'emptying', | |
}, | |
} | |
}, | |
emptying: { | |
id: 'empty-old', | |
on: { | |
'': { | |
actions: 'emptyOld', | |
target: 'emptied', | |
}, | |
} | |
}, | |
} | |
}, | |
{ | |
actions: { | |
emptyOld: (context, event) => { | |
console.log('loading new group...') | |
}, | |
loadNew: (context, event) => { | |
console.log('loading new group...') | |
}, | |
skipCurrent: (context, event) => { | |
console.log('skip this...') | |
}, | |
}, | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment