Skip to content

Instantly share code, notes, and snippets.

@martypenner
Last active July 22, 2019 23:30
Show Gist options
  • Save martypenner/9a151b737ad68402373f10f7e7dad457 to your computer and use it in GitHub Desktop.
Save martypenner/9a151b737ad68402373f10f7e7dad457 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
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