Last active
July 13, 2020 16:41
-
-
Save bfillmer/aaf56d9a0d1c52a99ae1993f62a08ac3 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
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