Created
February 6, 2020 05:57
-
-
Save ndisampson/bce521a58774eb7af734337e076fd6f6 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
const fetchMachine = Machine({ | |
id: 'fetch', | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { FETCH: 'loading' } | |
}, | |
loading: { | |
after: { | |
3000: 'failure.timeout' | |
}, | |
on: { | |
RESOLVE: 'success', | |
REJECT: 'failure', | |
TIMEOUT: 'failure.timeout' // manual timeout | |
}, | |
meta: { | |
message: 'Loading...' | |
} | |
}, | |
success: { | |
meta: { | |
message: 'The request succeeded!' | |
} | |
}, | |
failure: { | |
initial: 'rejection', | |
states: { | |
rejection: { | |
meta: { | |
message: 'The request failed.' | |
} | |
}, | |
timeout: { | |
meta: { | |
message: 'The request timed out.' | |
} | |
} | |
}, | |
meta: { | |
alert: 'Uh oh.' | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment