Last active
June 8, 2021 17:03
-
-
Save pke/c269c2f44f83543d1d6a917a73f5d35c 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: '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