Skip to content

Instantly share code, notes, and snippets.

@kid-icarus
Created March 1, 2021 19:12
Show Gist options
  • Save kid-icarus/15372cdecbd17706bff9d57c2212dbbc to your computer and use it in GitHub Desktop.
Save kid-icarus/15372cdecbd17706bff9d57c2212dbbc 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: 'unwell',
initial: 'unwell',
context: {
retries: 0
},
states: {
unwell: {
on: {
IS_HUNGRY: 'hungry',
ALREADY_ATE: 'medication'
}
},
hungry: {
on: {
EAT_MEAL: 'medication',
SNACK: 'medication',
}
},
medication: {
on: {
TAKE_MEDS: 'fluid',
NEED: 'medication',
},
},
fluid: {
on: {
DRINK: 'sleep',
NEED: 'fluid'
}
},
sleep: {
on: {
NAP: 'sleep',
RESTED: 'pain'
}
},
pain: {
on: {
NO: 'temperature',
YES: 'pain',
TAKE_PILL: 'temperature'
}
},
temperature: {
on: {
COLD: 'temperature',
HOT: 'temperature',
JUST_RIGHT: 'is_room_dirty'
}
},
is_room_dirty: {
on: {
DIRTY: 'is_room_dirty',
CLEAN: 'alone_or_too_many_people'
}
},
alone_or_too_many_people: {
on: {
GOOD: 'is_body_dirty',
REACH_OUT: 'is_body_dirty',
LEAVE: 'is_body_dirty'
}
},
is_body_dirty: {
on: {
DIRTY: 'is_body_dirty',
CLEAN: 'is_something_on_mind'
}
},
is_something_on_mind: {
on: {
YES: 'is_something_on_mind',
NO: 'success'
}
},
success: {
type: 'final'
},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment