Skip to content

Instantly share code, notes, and snippets.

@dpraimeyuu
Last active July 15, 2021 06:55
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 dpraimeyuu/8d1b954f4346b35e4e21523b17b4b4e2 to your computer and use it in GitHub Desktop.
Save dpraimeyuu/8d1b954f4346b35e4e21523b17b4b4e2 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: 'IDLE',
context: {
search_term: ""
},
states: {
IDLE: {
on: {
AUTOCOMPLETE_CLICKED: "ALL_SUGGESTIONS"
}
},
ALL_SUGGESTIONS: {
on: {
SUGGESTION_CLICKED: "FINAL",
SEARCH_TERM_CHANGED: "SEARCHING_STARTED"
}
},
SEARCHING_STARTED: {
on: {
NO_SUGGESTIONS_APPEARED: "NO_SUGGESTIONS",
SOME_SUGGESTIONS_APPEARED: "SOME_SUGGESTIONS"
}
},
SOME_SUGGESTIONS: {
on: {
SUGGESTION_CLICKED: "FINAL",
SEARCH_TERM_CHANGED: "SEARCHING_STARTED",
DELETE_CLICKED: "ALL_SUGGESTIONS"
}
},
NO_SUGGESTIONS: {
on: {
SEARCH_TERM_CHANGED: "SEARCHING_STARTED",
DELETE_CLICKED: "ALL_SUGGESTIONS"
}
},
FINAL: {}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment