Skip to content

Instantly share code, notes, and snippets.

@piojablonski
Last active April 3, 2020 12:59
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 piojablonski/c556d6def90437fa64462aed4cdbaf0f to your computer and use it in GitHub Desktop.
Save piojablonski/c556d6def90437fa64462aed4cdbaf0f to your computer and use it in GitHub Desktop.
Form Machine
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const formMachine = Machine({
id: 'form',
initial: 'loading',
states: {
loading: {
on: {
'': {
target: 'displayForm'
}
}
},
displayForm: {
on: {
SUBMIT: 'submitting',
SKIP: 'notCompleted'
}
},
submitting: {
invoke: {
src: 'createOutcome',
onDone: 'completed'
}
},
notCompleted: {
type: 'final'
},
completed: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment