Skip to content

Instantly share code, notes, and snippets.

@2WheelCoder
Created November 5, 2020 19:48
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 2WheelCoder/438dc1c7ccc87615fc050705fb628525 to your computer and use it in GitHub Desktop.
Save 2WheelCoder/438dc1c7ccc87615fc050705fb628525 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const setCategory = assign({
category: (context, event) => event.category
})
const fetchMachine = Machine({
id: 'download',
initial: 'acceptingCategory',
context: {
category: null
},
states: {
acceptingCategory: {
on: {
SUBMIT: {
target: 'acceptingMetricType',
actions: 'setCategory'
}
}
},
acceptingMetricType: {
on: {
SUBMIT: 'success',
}
},
success: {
type: 'final'
}
// failure: {
// on: {
// RETRY: {
// target: 'loading',
// actions: assign({
// retries: (context, event) => context.retries + 1
// })
// }
// }
// }
},
},
{
actions: { setCategory },
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment