Skip to content

Instantly share code, notes, and snippets.

@pke
Last active June 8, 2021 17:03
Show Gist options
  • Save pke/c269c2f44f83543d1d6a917a73f5d35c to your computer and use it in GitHub Desktop.
Save pke/c269c2f44f83543d1d6a917a73f5d35c 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: 'scanning',
context: {
qrcode: "",
sourceScreen: "fav", // rdonly
targetScreen: "", // write
targetScreenParams: {} // write
},
states: {
scanning: {
on: {
SCANNED: "validate",
}
},
validate: {
on: {
URL: "checkFavorite",
OTHER: "error"
},
},
checkFavorite: {
on: {
IS_FAV: "showFullScreen",
NOT_FAV: "saveFavorite",
}
},
showFullScreen: {
type: 'final'
},
saveFavorite: {
on: {
SAVED: "showFullScreen",
}
},
error: {
on: {
RETRY: "scanning",
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment