Created
September 29, 2020 23:25
-
-
Save faneder/099c7bc3dced9b3d4a1829acd7e61249 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const isAllRejected = () => {} | |
const isAllSucceed = () => {} | |
const allSucceed = (event) => event.data.every( | |
(response) => response.status === 'fulfilled' | |
); | |
const assignCounts = () => {} | |
const assignErrorMessages = () => {} | |
const fetchMachine = Machine({ | |
id: 'home', | |
initial: 'loading', | |
context: { | |
capGuardrailsWorkItemsCount: undefined, | |
newModelPriceWorkItemsCount: undefined, | |
modelPricePeerReviewWorkItemsCount: undefined, | |
colourLeverPeerReviewWorkItemsCount: undefined, | |
missingLeverWorkItemsCount: undefined, | |
missingLcvPriceWorkItemsCount: undefined, | |
overAgeCarWorkItemsCount: undefined, | |
nearlyNewCarWorkItemsCount: undefined, | |
errorMessages: undefined, | |
}, | |
states: { | |
loading: { | |
invoke: { | |
id: 'getWorkItems', | |
src: () => { | |
return | |
Promise.allSettled([ | |
getCapGuardrails(), | |
getNewModelPrices(), | |
getModelPricePeerReviewBatches(), | |
getColourLeverPeerReviewBatches(), | |
getMissingLever(), | |
getMissingLcvPrice(), | |
getOverAgeCars(), | |
getNearlyNewCars(), | |
]); | |
}, | |
onDone: [ | |
{ | |
target: 'worklistsError', | |
cond: isAllRejected, | |
}, | |
{ | |
target: 'displayWorklists.default', | |
cond: isAllSucceed, | |
actions: 'assignCounts', | |
}, | |
{ | |
target: 'displayWorklists.worklistError.active', | |
actions: ['assignErrorMessages', 'assignCounts'], | |
}, | |
], | |
}, | |
}, | |
displayWorklists: { | |
id: 'displayWorklists', | |
type: 'parallel', | |
states: { | |
default: {}, | |
worklistError: { | |
initial: 'inactive', | |
states: { | |
active: {}, | |
inactive: {}, | |
}, | |
}, | |
}, | |
}, | |
emptyWorklists: {}, | |
worklistsError: {}, | |
}, | |
}, | |
{ actions: { assignCounts, assignErrorMessages } }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment