Skip to content

Instantly share code, notes, and snippets.

@rickysullivan
Last active August 13, 2020 12:21
Show Gist options
  • Save rickysullivan/7487c6d63b4735206c1098011c5fe8f0 to your computer and use it in GitHub Desktop.
Save rickysullivan/7487c6d63b4735206c1098011c5fe8f0 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const repMachine = Machine(
{
id: "formWorkflowApp",
initial: "loggedOut",
states: {
loggedOut: {
on: {
"LOGIN.TAP": "loggedIn.idle",
},
},
loggedIn: {
states: {
idle: {
on: {
"SELL_DEBT.TAP": {
target: "formBuilder.idle",
actions: "setSaleType",
},
"SELL_TERMS.TAP": "formBuilder.idle",
"SELL_TRADIES_PACK.TAP": "formBuilder.idle",
},
},
formBuilder: {
context: {
saleType: "",
},
states: {
idle: {
on: {
"": [
{ target: "sellDebt" },
{
target: "sellTerms",
actions: (context, event) => {
console.log("activating...");
},
},
{ target: "sellTradiesPack" },
],
},
},
sellDebt: {},
sellTerms: {},
sellTradiesPack: {},
},
},
},
on: {
"LOGOUT.TAP": "loggedOut",
},
},
},
},
{
actions: {
setSaleType: (context, event, actionMeta) => {
console.log(context, event, actionMeta);
return;
},
},
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment