Skip to content

Instantly share code, notes, and snippets.

@alinzk
Created March 24, 2021 10:06
Show Gist options
  • Save alinzk/cd992232ee17565cf998dba18b7d74c5 to your computer and use it in GitHub Desktop.
Save alinzk/cd992232ee17565cf998dba18b7d74c5 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 flowMachine = Machine({
id: 'flow',
initial: 'idle',
states: {
idle: {
on: {
start: 'jobKind'
}
},
jobKind: {
meta: {
question: "Which healthcare field do you work in?"
},
on: {
nursing: 'jobPositionNursing',
elderlyCare: 'jobPositionElderlyCare',
medical: 'jobPositionMedical',
other: 'jobPositionOther'
}
},
jobPositionNursing: {
on: {
nursingAssistant: 'trainingType',
registeredNurse: 'department',
wardSister: 'department',
careManager: 'department',
other: 'department',
}
},
jobPositionElderlyCare: {
on: {
'*': 'cityPreference'
}
},
jobPositionMedical: {
on: {
'doctor': 'jobPositionDoctor',
'dentist': 'cityPreference'
}
},
jobPositionDoctor: {
on: {
registrar: 'doctorSpecialty',
specialtyRegistrar: 'doctorSpecialty',
consultant: 'doctorSpecialty',
seniorConsultant: 'doctorSpecialty',
generalPractitioner: 'doctorSpecialty',
}
},
jobPositionOther: {
on: {
'*': 'cityPreference'
}
},
doctorSpecialty: {
on: {
'*': 'cityPreference'
}
},
department: {
on: {
'*': 'cityPreference'
}
},
trainingType: {
on: {
no: "department",
yesBasic: "department",
yesBasicTraining: "department"
}
},
cityPreference: {
on: {
"*": "end"
}
},
end: {
type: 'final'
}
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment