Skip to content

Instantly share code, notes, and snippets.

@schicks
Created September 1, 2021 16:31
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 schicks/c553772398b0644cbdc54ae3e9695f4e to your computer and use it in GitHub Desktop.
Save schicks/c553772398b0644cbdc54ae3e9695f4e 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',
states: {
idle: {
on: {
INPUT: 'debounce'
}
},
debounce: {
entry: [
actions.cancel('debounceTimer'),
actions.send(
{type: 'DELAYED'},
{delay: 3000, id: 'debounceTimer'}
)
],
on: {
INPUT: 'debounce',
DELAYED: 'loading'
}
},
loading: {
on: {
INPUT: 'debounce',
RESOLVE: 'success'
}
},
success: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment