Skip to content

Instantly share code, notes, and snippets.

@wmonk
Last active March 4, 2021 09:23
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 wmonk/65c17e6fa0b74fcc510cee8be80d5916 to your computer and use it in GitHub Desktop.
Save wmonk/65c17e6fa0b74fcc510cee8be80d5916 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: 'fetch',
initial: 'checkLoggedIn',
states: {
checkLoggedIn: {
on: {
SUCCESS: "fetchAccount",
ERROR: "requireLogin"
}
},
requireLogin: {
on: {
SUCCESS: "fetchAccount"
}
},
fetchAccount: {
on: {
SUCCESS: "fetchPets",
ERROR: "createAccount"
}
},
fetchPets: {
on: {
SUCCESS: "checkNotificationAccess",
ERROR: "createPet"
}
},
createPet: {
on: {
SUCCESS: "checkNotificationAccess",
ERROR: "errored"
}
},
checkNotificationAccess: {
on: {
GRANTED: "done",
REJECTED: "done",
REQUEST: "requestNotificationAccess"
}
},
requestNotificationAccess: {
on: {
GRANTED: "done",
SKIPPED: "done"
}
},
createAccount: {
on: {
SUCCESS: "fetchPets",
ERROR: "errored"
}
},
errored: {
},
done: {
type: "final"
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment