Skip to content

Instantly share code, notes, and snippets.

@ragrum
Last active April 15, 2021 01:58
Show Gist options
  • Save ragrum/2500abda17ed3ab53c00738e241acf85 to your computer and use it in GitHub Desktop.
Save ragrum/2500abda17ed3ab53c00738e241acf85 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)
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