Created
January 4, 2021 04:52
-
-
Save cblanc/8294eabe0f513a72aa270e809ca81ba9 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
const INPUT = { INPUT: { actions: "input" } }; | |
const CLOSE = { CLOSE: "closed" }; | |
const SUGGEST = { SUGGEST: "suggesting" }; | |
const NOTIFY = { NOTIFY: "notifying" }; | |
const fetchMachine = Machine({ | |
initial: "closed", | |
context: { | |
suggestions: [], | |
message: "Start typing to find address", | |
}, | |
states: { | |
closed: { | |
entry: ["close", "onClose"], | |
exit: ["onOpen", "open"], | |
on: { | |
AWAKE: [ | |
{ | |
target: "suggesting", | |
cond: (c) => c.suggestions.length > 0, | |
}, | |
{ | |
target: "notifying", | |
}, | |
], | |
}, | |
}, | |
notifying: { | |
entry: ["updateMessage", "showMessage"], | |
on: { | |
...CLOSE, | |
...SUGGEST, | |
...NOTIFY, | |
...INPUT, | |
}, | |
}, | |
suggesting: { | |
entry: ["updateSuggestions", "renderSuggestions"], | |
on: { | |
...CLOSE, | |
...SUGGEST, | |
...NOTIFY, | |
...INPUT, | |
NEXT: { actions: "next" }, | |
PREVIOUS: { actions: "previous" }, | |
SELECT: { actions: "select" }, | |
}, | |
}, | |
}, | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment