Created
January 29, 2020 18:27
-
-
Save hnordt/f09cbb7f7cb4426fddfe634c391ec512 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({ | |
id: "resource", | |
context: { | |
params: {}, | |
data: null, | |
meta: {} | |
}, | |
initial: "idle", | |
states: { | |
idle: {}, | |
fetching: { | |
entry: "resetData", | |
invoke: { | |
src: "fetch", | |
onDone: { | |
target: "success", | |
actions: ["setData", "setMeta"] | |
}, | |
onError: { | |
target: "failure", | |
actions: ["setData", "setMeta"] | |
} | |
} | |
}, | |
debouncing: { | |
after: { | |
500: "refetching" | |
} | |
}, | |
refetching: { | |
invoke: { | |
src: "fetch", | |
onDone: { | |
target: "success", | |
actions: ["setData", "setMeta"] | |
}, | |
onError: { | |
target: "failure", | |
actions: ["setData", "setMeta"] | |
} | |
} | |
}, | |
success: { | |
entry: "notifySuccess" | |
}, | |
failure: { | |
entry: "notifyFailure", | |
on: { | |
RETRY: "fetching" | |
} | |
} | |
}, | |
on: { | |
FETCH: { | |
target: "fetching", | |
actions: "setParams" | |
}, | |
REFETCH: { | |
target: "debouncing", | |
actions: "setParams" | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment