Last active
August 30, 2019 12:55
-
-
Save vuhrmeister/d0d15efbf0d30ed9f1388ec9e520de6b 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 appMachine = Machine({ | |
id: 'app', | |
type: 'parallel', | |
context: { | |
setupDone: true // TODO must be false, true for now to skip setup | |
}, | |
states: { | |
update: { | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
ALLOW_UPDATES: 'activated' | |
} | |
}, | |
activated: { | |
on: { | |
DISALOW_UPDATES: 'idle' | |
} | |
} | |
} | |
}, | |
workflow: { | |
initial: 'unknown', | |
states: { | |
unknown: { | |
on: { | |
'': [ | |
{ target: 'auth', cond: 'isSetupDone' }, | |
{ target: 'setupDevice' } | |
] | |
} | |
}, | |
setupDevice: { | |
on: { | |
DONE: { | |
target: 'auth', | |
actions: 'flagSetupDone' | |
} | |
}, | |
meta: { | |
isNavState: true | |
} | |
}, | |
auth: { | |
// Updates should be allowed only on the auth screen | |
// to not interrupt the user workflow | |
onEntry: raise('ALLOW_UPDATES'), | |
onExit: raise('DISALOW_UPDATES'), | |
on: { | |
AUTHENTICATED: 'checkIn' | |
}, | |
meta: { | |
isNavState: true | |
} | |
}, | |
checkIn: { | |
on: { | |
DONE: 'tour', | |
CANCEL: { | |
target: 'auth', | |
actions: 'logout' | |
} | |
}, | |
meta: { | |
isNavState: true | |
} | |
}, | |
tour: { | |
on: { | |
DONE: 'checkOut' | |
}, | |
meta: { | |
isNavState: true | |
} | |
}, | |
checkOut: { | |
on: { | |
DONE: 'done', | |
BACK: 'tour' | |
}, | |
meta: { | |
isNavState: true | |
} | |
}, | |
done: { | |
type: 'final' | |
} | |
}, | |
// Start over | |
onDone: '.unknown' | |
} | |
} | |
}, { | |
actions: { | |
flagSetupDone: assign({ | |
setupDone: () => true | |
}) | |
}, | |
guards: { | |
isSetupDone: ctx => ctx.setupDone | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment