Skip to content

Instantly share code, notes, and snippets.

@wlee221
Last active April 19, 2021 21:28
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 wlee221/5c90427817c5e5bbc985bfb8d5c69a78 to your computer and use it in GitHub Desktop.
Save wlee221/5c90427817c5e5bbc985bfb8d5c69a78 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)
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine({
id: 'signUp',
initial: 'edit',
context: {
error: {},
formData: {}
},
states: {
edit: {
initial: 'pristine',
on: {
SUBMIT: 'validate',
CHANGE: {
target: '',
actions: 'onChange'
},
},
states: {
pristine: {},
error: {}
}
},
validate: {
on: {
SIGN_UP: 'signUp',
ERROR: 'edit.error',
},
},
signUp: {
invoke: {
src: 'signUp',
onDone: {
action: 'setUser',
target: 'resolved',
},
onError: {
target: "edit.error"
}
}
},
resolved: {}
}
}, {
actions: {
onChange: assign({
// update form data...
})
},
services: {
signUp: () => {}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment