Created
November 10, 2019 22:04
-
-
Save pke/ac90dc3ae16d407369c6341f29c2b10c 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