Created
July 21, 2019 16:59
-
-
Save Platekun/b1c3a9dcfaf78e9d77f118f6cf8a3f0a to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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
Machine({ | |
id: 'Cats Fetcher', | |
initial: 'idle', | |
context: { | |
cats: null, | |
error: null | |
}, | |
states: { | |
idle: { | |
on: { | |
QUERY_UPDATED: { | |
actions: 'updateQuery' | |
}, | |
SEARCH: 'searching' | |
} | |
}, | |
searching: { | |
invoke: { | |
id: 'catsRequest', | |
src: () => Promise.resolve([]), | |
onDone: { | |
target: 'idle', | |
actions: 'saveCats' | |
}, | |
onError: { | |
taret: 'searchFailure', | |
actions: 'saveCats' | |
} | |
} | |
}, | |
searchFailure: { | |
on: { | |
RETRY: { | |
target: 'searching', | |
actions: 'clearError' | |
} | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment