Created
June 15, 2021 18:39
-
-
Save kbingman/27c8b9d466129a0e1dc98ac71e11cd67 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-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