Skip to content

Instantly share code, notes, and snippets.

@adamkl
Created Dec 4, 2019
Embed
What would you like to do?
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: "hiring_pipeline",
context: {
phone_screen_score: null,
hacker_rank_score: null,
fit_score: null,
codepair_score: null
},
initial: "new",
states: {
new: {
on: {
START: "phone_screen_pending"
}
},
phone_screen_pending: {
on: {
PHONE_SCREEN_COMPLETE: [
{
target: "no_hire",
cond: (_, { score }) => score < 60
},
{
target: "hacker_rank_pending",
actions: assign((_, { score }) => ({ phone_screen_score: score }))
}
]
}
},
hacker_rank_pending: {
on: {
HACKER_RANK_COMPLETE: [
{
target: "no_hire",
cond: (_, { score }) => score < 60
},
{
target: "in_person_pending",
actions: assign((_, { score }) => ({ hacker_rank_score: score }))
}
]
}
},
in_person_pending: {
type: "parallel",
onDone: "hire",
states: {
fit_interview: {
initial: "pending",
states: {
pending: {
on: {
FIT_INTERVIEW_COMPLETE: [
{
target: "#hiring_pipeline.no_hire",
cond: (_, { score }) => score < 60
},
{
target: "complete",
actions: assign((_, { score }) => ({
fit_score: score
}))
}
]
}
},
complete: {
type: "final"
}
}
},
codepair_interview: {
initial: "pending",
states: {
pending: {
on: {
CODEPAIR_COMPLETE: [
{
target: "#hiring_pipeline.no_hire",
cond: (_, { score }) => score < 60
},
{
target: "complete",
actions: assign((_, { score }) => ({
codepair_score: score
}))
}
]
}
},
complete: {
type: "final"
}
}
}
}
},
hire: {
type: "final"
},
no_hire: {
type: "final"
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment