Skip to content

Instantly share code, notes, and snippets.

@xeBuz
Created May 9, 2022 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xeBuz/9b1ced23360c611a96bff6af94093d05 to your computer and use it in GitHub Desktop.
Save xeBuz/9b1ced23360c611a96bff6af94093d05 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'submission-state-machine',
initial: 'draft',
context: {},
states: {
draft: {
on: {
SUBMIT: { target: 'preModeration' },
DELETE: { target: 'deleted' },
REPORT: { target: 'reported' },
},
},
preModeration: {
on: {
APPROVE: { target: 'waitingModeration' },
REJECT: { target: 'rejected' },
},
},
waitingModeration: {
on: {
MODERATE: { target: 'inModeration' },
},
},
inModeration: {
on: {
APPROVE: { target: 'approved' },
REJECT: { target: 'rejected' },
DELETE: { target: 'deleted' },
},
},
approved: {
on: {
SELECT: { target: 'selected'},
REPORT: { target: 'reported' },
},
},
rejected: {
on: {
DRAFT: { target: 'draft' },
DELETE: { target: 'deleted' },
},
},
reported: {
on: {
REQUEUE: { target: 'waitingModeration' },
APPROVE: { target: 'approved' },
DRAFT: { target: 'draft' },
DELETE: { target: 'deleted' },
},
},
deleted: {
type: 'final',
},
selected: {
type: 'final',
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment