Skip to content

Instantly share code, notes, and snippets.

@massimoselvi
Last active June 27, 2022 07:36
Show Gist options
  • Save massimoselvi/0ab04d9bf6d58b03d82bd0609e178eb7 to your computer and use it in GitHub Desktop.
Save massimoselvi/0ab04d9bf6d58b03d82bd0609e178eb7 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// https://xstate.js.org/viz/?gist=0ab04d9bf6d58b03d82bd0609e178eb7
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine({
id: 'unlock',
initial: 'locked',
context: {
retries: 0
},
states: {
locked: {
on: {
UNLOCK: 'unlocked',
OVERDUE: 'overdue',
}
},
unlocked: {
on: {
SUBMIT: 'submitted',
COMPLETE: 'completed',
OVERDUE: 'overdue',
}
},
submitted: {
type: 'final',
on: {
REVIEW: 'reviewed',
ASSESS: 'assessed',
REJECT: 'rejected',
}
},
reviewed: {
on: {
}
},
assessed: {
on: {
}
},
rejected: {
on: {
}
},
completed: {
on: {
RETRY: {
target: 'unlocked',
actions: assign({
retries: (context, event) => context.retries + 1
})
}
}
},
overdue: {
// final
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment