Last active
April 3, 2020 12:59
-
-
Save piojablonski/c556d6def90437fa64462aed4cdbaf0f to your computer and use it in GitHub Desktop.
Form Machine
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) | |
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