Last active
July 22, 2019 23:30
-
-
Save martypenner/9a151b737ad68402373f10f7e7dad457 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
const machine = Machine( | |
{ | |
id: 'debouncedFetchLatest', | |
initial: 'idle', | |
states: { | |
idle: {}, | |
success: {}, | |
failure: { | |
initial: 'other', | |
states: { | |
other: {}, | |
timeout: {} | |
} | |
}, | |
preparing_to_fetch: { | |
after: { | |
FETCH_DELAY: 'fetching' | |
} | |
}, | |
fetching: { | |
after: { | |
TIMEOUT: 'failure.timeout' | |
}, | |
invoke: { | |
src: 'fetch', | |
onDone: { | |
target: 'success' | |
}, | |
onError: { | |
target: 'failure' | |
} | |
} | |
} | |
}, | |
on: { | |
FETCH: 'preparing_to_fetch' | |
} | |
}, | |
{ | |
delays: { | |
FETCH_DELAY: 300, | |
TIMEOUT: 30000 | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment