Last active
June 27, 2022 07:36
-
-
Save massimoselvi/0ab04d9bf6d58b03d82bd0609e178eb7 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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