Skip to content

Instantly share code, notes, and snippets.

@GABAnich
Created March 29, 2021 20:29
Show Gist options
  • Save GABAnich/ca02eeb27ebcb1cfc426012fa9e62fa9 to your computer and use it in GitHub Desktop.
Save GABAnich/ca02eeb27ebcb1cfc426012fa9e62fa9 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: 'vacation',
initial: 'idle',
states: {
idle: {
on: {
REQUEST: 'waiting_for_manager_approve'
}
},
waiting_for_manager_approve: {
on: {
MANAGER_APPROVE: 'waiting_for_team_approve.one_of_three',
MANAGER_REJECT: 'rejected'
}
},
waiting_for_team_approve: {
states: {
one_of_three: {
on: {
TEAM_APPROVE: 'two_of_three',
TEAM_REJECT: '#vacation.rejected'
}
},
two_of_three: {
on: {
TEAM_APPROVE: 'three_of_three',
TEAM_REJECT: '#vacation.rejected'
}
},
three_of_three: {
on: {
TEAM_APPROVE: '#vacation.approved',
TEAM_REJECT: '#vacation.rejected'
}
}
}
},
approved: {
type: 'final'
},
rejected: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment