Created
May 6, 2021 01:49
-
-
Save schpet/7fe129af3f09952617fb0c96a5bc2a5c 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const fetchMachine = Machine({ | |
id: "contacts", | |
initial: "pending", | |
context: { | |
contacts: undefined, | |
}, | |
states: { | |
pending: { | |
on: { | |
INITIATE: "permission_requested", | |
SKIP: "nudge", | |
}, | |
}, | |
permission_requested: { | |
invoke: { | |
src: "requestPermission", | |
onDone: { target: "reading_contacts" }, | |
onError: { target: "permission_denied" }, | |
}, | |
}, | |
reading_contacts: { | |
invoke: { | |
src: "saveContacts", | |
onDone: "pending", | |
onError: "failed", | |
}, | |
}, | |
complete: { | |
type: "final", | |
}, | |
nudge: { | |
on: { | |
INITIATE: "permission_requested", | |
SKIP: "skipped", | |
DISMISS: "pending", | |
}, | |
entry: ["showNudgeSheet"], | |
exit: ["hideNudgeSheet"], | |
}, | |
skipped: { | |
invoke: { | |
src: "skip", | |
onDone: "pending", | |
}, | |
}, | |
failed: { | |
on: { | |
RETRY: "permission_requested", | |
SKIP: "skipped", | |
}, | |
}, | |
permission_denied: { | |
on: { RETRY: "permission_requested", SKIP: "skipped" }, | |
}, | |
}, | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment