Last active
December 3, 2019 10:20
-
-
Save oscargm/2c26dac9f89838b6a661bf93364347d9 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
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const fetchMachine = Machine({ | |
id: 'fetch', | |
initial: 'idle', | |
context: { | |
selectedStatus: null | |
}, | |
states: { | |
idle: { | |
on: { | |
FETCH: 'loading' | |
} | |
}, | |
loading: { | |
after: { | |
3000: 'failure.timeout' | |
}, | |
on: { | |
RESOLVE: 'success', | |
REJECT: 'failure.rejection', | |
TIMEOUT: 'failure.timeout' // manual timeout | |
}, | |
}, | |
success: { | |
on: { | |
SELECTSTATUS: 'statusSelected' | |
} | |
}, | |
failure: { | |
type: 'final', | |
initial: 'rejection', | |
states: { | |
rejection: { | |
meta: { | |
message: 'The request failed.' | |
} | |
}, | |
timeout: { | |
meta: { | |
message: 'The request timed out.' | |
} | |
} | |
}, | |
}, | |
statusSelected: { | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment