Skip to content

Instantly share code, notes, and snippets.

@kbingman
Created June 15, 2021 18:39
Show Gist options
  • Save kbingman/27c8b9d466129a0e1dc98ac71e11cd67 to your computer and use it in GitHub Desktop.
Save kbingman/27c8b9d466129a0e1dc98ac71e11cd67 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-machine',
initial: 'idle',
context: {
q: '',
offset: 0,
size: 10,
},
states: {
idle: {
on: {
SEARCH: {
target: 'pending',
},
},
},
pending: {
invoke: {
id: 'fetch-results',
src: 'invokeFetchResults',
onDone: 'success',
onError: 'failure',
},
},
success: {
on: {SEARCH: {
target: 'pending',
},
FILTER: {
target: 'pending'
},
RESET: {
target: 'idle',
},},
},
failure: {
on: {SEARCH: {
target: 'pending',
},
RESET: {
target: 'idle',
}
},
},
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment