Last active
April 19, 2021 21:28
-
-
Save wlee221/5c90427817c5e5bbc985bfb8d5c69a78 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
// 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