Skip to content

Instantly share code, notes, and snippets.

@joaom182
Created November 9, 2021 23:19
Show Gist options
  • Save joaom182/e81dbaef1ba925faedeb262ef92801aa to your computer and use it in GitHub Desktop.
Save joaom182/e81dbaef1ba925faedeb262ef92801aa to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine({
id: 'entityProfiles',
initial: 'profiles',
states: {
init: {
always: [
{ target: 'profile-confirm-page' },
{ target: 'profiles' }
]
},
profiles: {
entry: ['clearSelectedEntityId'],
on: {
NEXT: {
target: 'profiles-edit',
actions: ['assignApplication']
}
}
},
'profiles-edit': {
entry: ['clearSelectedEntityId'],
on: {
NEXT: [
{
target: 'loop'
},
{
target: 'profile-confirm-page',
actions: ['assignApplication']
}
]
}
},
loop: {
exit: ['clearCurrentEntityCards'],
on: {
NEXT: [
{
target: 'profiles-edit',
actions: ['assignAllFromData', 'assignEntityCards']
},
{
target: 'loop'
}
],
BACK: [
{
target: 'profiles-edit',
actions: ['assignApplication']
},
{
target: 'loop'
}
]
}
},
'profile-confirm-page': {
entry: ['clearSelectedEntityId'],
exit: ['clearCurrentEntityCards', 'assignIsVisited'],
on: {
NEXT: {
target: 'success',
actions: ['assignApplication']
},
BACK: {
target: 'profiles-edit',
actions: ['assignApplication']
}
}
},
'success': {
exit: ['clearSelectedEntityId', 'clearCurrentEntityCards'],
type: 'final'
}
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment