Skip to content

Instantly share code, notes, and snippets.

@davidkpiano
Last active March 31, 2020 18:55
Show Gist options
  • Save davidkpiano/3401066b7f780e5db5a386cafc264ee2 to your computer and use it in GitHub Desktop.
Save davidkpiano/3401066b7f780e5db5a386cafc264ee2 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'questionnaire',
initial: 'symptoms',
states: {
symptoms: {
on: {
NEXT: 'fluTest'
}
},
fluTest: {
on: {
NEXT: [
{
target: 'fluResults',
cond: 'answeredYes'
},
{
target: 'exposure'
}
]
}
},
fluResults: {
on: {
NEXT: 'exposure'
}
},
exposure: {
on: {
NEXT: [
{
target: 'exposureTime',
cond: 'answeredYes'
},
{
target: 'travel'
}
]
}
},
exposureTime: {
on: {
NEXT: 'travel'
}
},
travel: {
on: {
NEXT: 'additional'
}
},
additional: {
on: {
NEXT: 'evaluating'
}
},
evaluating: {
after: {
3000: [
{
target: 'preregister',
cond: 'testRecommended'
},
{
target: 'notAtRisk'
}
]
}
},
preregister: {
on: {
NEXT: [
{
target: 'patient',
cond: 'answeredYes'
},
{
target: 'confirmation'
}
]
}
},
patient: {
on: {
NEXT: 'map'
}
},
notAtRisk: {},
map: {
on: {
NEXT: 'confirmation'
}
},
confirmation: {}
}
}, {
guards: {
answeredYes: (_, e) => true,
testRecommended: (_, e) => true
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment