Last active
July 20, 2019 01:14
-
-
Save hnordt/0399da2ecbfa6e715fe6b98c406d6785 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
let approvalsMachine = Machine( | |
{ | |
id: "approvals", | |
context: { | |
dateStart: "", | |
dateEnd: "", | |
page: 0, | |
results: [], | |
items: {}, | |
error: null | |
}, | |
type: "parallel", | |
states: { | |
loadApprovals: { | |
initial: "idle", | |
states: { | |
idle: { | |
initial: "nonMdm", | |
states: { | |
nonMdm: { | |
on: { | |
TOGGLE_MDM: "mdm" | |
} | |
}, | |
mdm: { | |
on: { | |
TOGGLE_MDM: "nonMdm" | |
} | |
} | |
}, | |
on: { | |
PREV_PAGE: "prevPage", | |
NEXT_PAGE: "nextPage" | |
} | |
}, | |
prevPage: { | |
initial: "loading", | |
states: { | |
loading: { | |
entry: "decrementPage", | |
invoke: { | |
src: "getResults", | |
onDone: "success", | |
onError: "failure" | |
} | |
}, | |
success: { | |
entry: "setResults", | |
type: "final" | |
}, | |
failure: { | |
entry: ["incrementPage", "setError"], | |
exit: "resetError", | |
on: { | |
RETRY: "loading", | |
CANCEL: "canceled" | |
} | |
}, | |
canceled: { | |
type: "done" | |
} | |
}, | |
onDone: "idle" | |
}, | |
nextPage: { | |
initial: "loading", | |
states: { | |
loading: { | |
entry: "incrementPage", | |
invoke: { | |
src: "getResults", | |
onDone: "success", | |
onError: "failure" | |
} | |
}, | |
success: { | |
entry: "setResults", | |
type: "final" | |
}, | |
failure: { | |
entry: ["incrementPage", "setError"], | |
exit: "resetError", | |
on: { | |
RETRY: "loading", | |
CANCEL: "canceled" | |
} | |
}, | |
canceled: { | |
type: "done" | |
} | |
}, | |
onDone: "idle" | |
} | |
} | |
}, | |
submitApprovals: { | |
initial: "some", | |
states: { | |
some: { | |
initial: "idle", | |
states: { | |
idle: { | |
on: { | |
SELECT_ITEM: { | |
actions: "selectItem" | |
}, | |
SUBMIT: "loading" | |
} | |
}, | |
loading: { | |
invoke: { | |
src: "sendApprovals", | |
onDone: "success", | |
onError: "failure" | |
} | |
}, | |
success: { | |
on: { | |
DONE: "idle" | |
} | |
}, | |
failure: { | |
entry: "setError", | |
exit: "resetError", | |
on: { | |
RETRY: "loading", | |
CANCEL: "idle" | |
} | |
} | |
}, | |
on: { | |
TOGGLE_ALL: "all" | |
} | |
}, | |
all: { | |
initial: "idle", | |
states: { | |
idle: { | |
on: { | |
SUBMIT: "loading" | |
} | |
}, | |
loading: { | |
invoke: { | |
src: "approveAll", | |
onDone: "success", | |
onError: "failure" | |
} | |
}, | |
success: { | |
on: { | |
DONE: "idle" | |
} | |
}, | |
failure: { | |
entry: "setError", | |
exit: "resetError", | |
on: { | |
RETRY: "loading", | |
CANCEL: "idle" | |
} | |
} | |
}, | |
on: { | |
TOGGLE_ALL: "some" | |
} | |
} | |
} | |
} | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment