Skip to content

Instantly share code, notes, and snippets.

@camwest
Created August 21, 2020 14:28
Show Gist options
  • Save camwest/1f09b6f4fb54c4e556b0330c94dbf069 to your computer and use it in GitHub Desktop.
Save camwest/1f09b6f4fb54c4e556b0330c94dbf069 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 increment = (context) => context.count + 1;
const decrement = (context) => context.count - 1;
const fetchMachine = Machine({
id: "root",
states: {
Delphia: {
id: "Delphia",
states: {
"iOS App": {
id: "iOS App",
states: {
"Logged Out": {
id: "Logged Out",
states: {},
on: {
"create account": "#Create Account",
login: "#Logged In",
"sign in with apple": "#Logged In",
},
},
"Create Account": {
id: "Create Account",
states: {
"Validate Email": {
id: "Validate Email",
states: {},
on: { "enter correct token": "#Logged In" },
},
},
initial: "Validate Email",
},
"Logged In": {
id: "Logged In",
states: {
"Core App": {
id: "Core App",
states: {
"Investing Screen": {
id: "Investing Screen",
states: {
"iOS Has Investment Account?": {
id: "iOS Has Investment Account?",
states: {},
on: {
no: "#No Investing Account",
yes: "#Native Coming Soon",
},
},
"Native Coming Soon": {
id: "Native Coming Soon",
states: {},
on: { "login to web": "#Web Application" },
},
"No Investing Account": {
id: "No Investing Account",
states: {},
on: { "open account": "#Web Application" },
},
},
initial: "iOS Has Investment Account?",
on: {},
},
"Data Vault": {
id: "Data Vault",
context: {
count: 0,
},
states: {
"Commitments Available?": {
id: "Commitments Available?",
states: {},
on: {
no: "#No Commitments Available",
yes: "#Commitments Available",
},
},
"Commitments Available": {
id: "Commitments Available",
states: {},
on: {
"connect app": "#Connect App",
},
},
"No Commitments Available": {
id: "No Commitments Available",
states: {},
},
"Connect App": {
id: "Connect App",
states: {},
on: { done: "#Commitments Available?" },
},
},
initial: "Commitments Available?",
on: {
INC: { actions: assign({ count: increment }) },
DEC: { actions: assign({ count: decrement }) },
},
},
Profile: { id: "Profile", states: {} },
},
initial: "Data Vault",
on: {
"data vault": "#Data Vault",
investing: "#Investing Screen",
profile: "#Profile",
},
},
},
initial: "Core App",
on: { "log out": "#Logged Out" },
},
},
initial: "Logged Out",
on: {},
},
},
initial: "iOS App",
on: {},
},
"Web Application": {
id: "Web Application",
states: {
"Web Has Investment Account?": {
id: "Web Has Investment Account?",
states: {},
on: {
funded: "#Account Funded",
no: "#No Custodian Account",
"not funded": "#No Funds",
},
},
"No Custodian Account": {
id: "No Custodian Account",
states: {},
on: { "open account": "#Active Custodian Account" },
},
"Active Custodian Account": {
id: "Active Custodian Account",
states: {
"CIP Approval": {
id: "CIP Approval",
states: {},
on: { approved: "#Link Bank" },
},
"Link Bank": {
id: "Link Bank",
states: {},
on: { "choose bank": "#No Funds" },
},
"No Funds": { id: "No Funds", states: {} },
"Account Funded": {
id: "Account Funded",
states: {
"Liquidation Pending": {
id: "Liquidation Pending",
states: {},
on: { "liquidation complete": "#Web Application" },
},
"Investment Automatically Rebalances": {
id: "Investment Automatically Rebalances",
states: {},
},
},
initial: "Investment Automatically Rebalances",
on: { "liquidate funds": "#Liquidation Pending" },
},
"Deposit Pending": {
id: "Deposit Pending",
states: {},
on: {
"deposit complete": "#Investment Automatically Rebalances",
},
},
},
initial: "CIP Approval",
on: {
"close account": "#No Custodian Account",
"create deposit": "#Deposit Pending",
},
},
},
initial: "Web Has Investment Account?",
on: {},
},
},
initial: "Delphia",
on: {},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment