Skip to content

Instantly share code, notes, and snippets.

@faneder
Created September 30, 2020 11:27
Show Gist options
  • Save faneder/3d200f52391cbfc8b85a3a638db3f587 to your computer and use it in GitHub Desktop.
Save faneder/3d200f52391cbfc8b85a3a638db3f587 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const isAllRejected = () => {}
const isAllSucceed = () => {}
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([
]);
},
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: {},
autoRefresh: {},
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