Skip to content

Instantly share code, notes, and snippets.

@LevelbossMike
Created November 22, 2022 10:07
Show Gist options
  • Save LevelbossMike/83359fae52c3620c35ab91802a8c24ca to your computer and use it in GitHub Desktop.
Save LevelbossMike/83359fae52c3620c35ab91802a8c24ca 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 fetchMachine = Machine({
initial: 'idle',
states: {
idle: {
on: {
SUBMIT: 'busy'
}
},
busy: {
invoke: {
src: 'handleSubmit',
onDone: 'success',
onError: 'error'
}
},
success: {
entry: ['handleSuccess'],
on: {
SUBMIT: 'busy'
}
},
error: {
entry: ['handleError'],
on: {
SUBMIT: 'busy'
}
}
}
}, {
actions: {
handleSuccess() {},
handleError() {}
},
services: {
handleSubmit: async () => {}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment