Skip to content

Instantly share code, notes, and snippets.

@joaom182
Created November 12, 2021 01:27
Show Gist options
  • Save joaom182/29f88b90632045cb13c053a519aac232 to your computer and use it in GitHub Desktop.
Save joaom182/29f88b90632045cb13c053a519aac232 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: 'documents-and-additional-questions',
initial: 'provide-documents',
entry: ['assignRootEntity', 'assignCurrentEntitiesFlat'],
states: {
'provide-documents': {
entry: ['clearCurrentEntityCards'],
on: {
NEXT: [
{
target: 'answer-questions',
cond: 'currentEntityNeedsAnswerQuestions'
},
{
target: 'provide-documents',
actions: ['assignNextEntity'],
cond: 'nextEntityNeedsProvideDocuments'
},
{
target: 'success'
}
],
BACK: [
{
target: 'answer-questions',
actions: ['assignPreviousEntity'],
cond: 'previousEntityNeedsAnswerQuestions'
},
{
target: 'provide-documents',
actions: ['assignPreviousEntity'],
cond: 'previousEntityNeedsProvideDocuments'
},
{
target: 'answer-questions',
actions: ['assignPreviousEntityThatNeedsAnswerQuestions'],
cond: 'hasSomePreviousEntityToAnswerQuestions'
},
{
target: 'provide-documents',
actions: ['assignPreviousEntityThatNeedsProvideDocuments'],
cond: 'hasSomePreviousEntityToProvideDocument'
}
]
}
},
'answer-questions': {
entry: ['clearCurrentEntityCards'],
on: {
NEXT: [
{
target: 'provide-documents',
actions: ['assignNextEntity'],
cond: 'nextEntityNeedsProvideDocuments'
},
{
target: 'answer-questions',
actions: ['assignNextEntity'],
cond: 'nextEntityNeedsAnswerQuestions'
},
{
target: 'success'
}
],
BACK: 'provide-documents'
}
},
exit: {
type: 'final',
entry: ['BACK']
},
success: {
type: 'final',
entry: ['NEXT']
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment