Skip to content

Instantly share code, notes, and snippets.

@bfillmer
Last active July 13, 2020 16:41
Show Gist options
  • Save bfillmer/aaf56d9a0d1c52a99ae1993f62a08ac3 to your computer and use it in GitHub Desktop.
Save bfillmer/aaf56d9a0d1c52a99ae1993f62a08ac3 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const cartsMachine = Machine({
id: 'carts',
initial: 'initial',
context: {},
states: {
initial: {
on: {
'HYDRATE': {
target: 'idle',
actions: ['hydrateContext']
}
}
},
loading: {
invoke: {
src: 'getCartsData',
onDone: 'idle',
onError: 'idle'
}
},
idle: {
on: {
FETCH: 'loading',
SET_ACTIVE: {
actions: ['setActive']
}
}
},
}
}, {
actions: {
setActive: (context, event) => null,
hydrateContext: assign((_, event) => event.data)
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment