Skip to content

Instantly share code, notes, and snippets.

@tsukhu
Last active July 14, 2020 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsukhu/4a5d80c5fbc7a406784fda052ed4d46b to your computer and use it in GitHub Desktop.
Save tsukhu/4a5d80c5fbc7a406784fda052ed4d46b to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const dataMachine = new Machine({
id: "posts",
initial: "ready",
context: {
data: [],
},
states: {
ready: {
on: {
FETCH_POSTS: "fetching"
}
},
fetching: {
invoke: {
src: 'fetchPosts',
onDone: {
target: "success",
actions: assign({
data: (_, event) => event.data
})
},
onError: "error"
}
},
success: { type: "final" },
error: { type: "final" }
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment