Skip to content

Instantly share code, notes, and snippets.

@GABAnich
Created March 29, 2021 20:45
Show Gist options
  • Save GABAnich/e70817e44a1dae3b414360eaf29be595 to your computer and use it in GitHub Desktop.
Save GABAnich/e70817e44a1dae3b414360eaf29be595 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',
MANAGER_REJECT: 'rejected'
}
},
waiting_for_team_approve: {
on: {
TEAM_APPROVE: {
target: 'approved',
cond: 'teamApprove'
},
TEAM_REJECT: 'rejected'
}
},
approved: {
type: 'final'
},
rejected: {
type: 'final'
}
},
guards: {
teamApprove: () => {
let count = 0; // get count from DB
count++;
if (count < 6) return false;
return true;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment