Last active
April 15, 2021 01:58
-
-
Save ragrum/2500abda17ed3ab53c00738e241acf85 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) | |
const context = { | |
id: "29890765241" | |
} | |
const guards = { | |
isEditMode: (context, event) => { | |
return !!context.clientId; | |
}, | |
isNewClientMode: (context, event) => { | |
return true; | |
}, | |
}; | |
clientFormMachine = Machine({ | |
id: "clientForm", | |
initial: "checkEditMode", | |
context: {...context}, | |
states: { | |
checkEditMode: { | |
always: [ | |
{ target: "editClientForm", cond: "isEditMode" }, | |
{ target: "newClientForm", cond: "isNewClientMode" }, | |
], | |
on: {}, | |
}, | |
editClientForm: {}, | |
newClientForm: {}, | |
}, | |
}, { guards }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment