Last active
March 5, 2020 16:30
-
-
Save eschaefer/668c6880eef24431b00b59b0bdca29f8 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 fetchMachine = Machine({ | |
id: "sidebar", | |
initial: "selfServeUser", | |
states: { | |
selfServeUser: { | |
initial: "not_purchased", | |
states: { | |
not_purchased: { | |
initial: "licenses", | |
states: { | |
licenses: { | |
on: { | |
"PACK.CLICK": "pack", | |
"SINGLE.CLICK": "single" | |
} | |
}, | |
pack: { | |
actions: ['show_download_button'] | |
}, | |
single: { | |
actions: ['show_cart_button'] | |
} | |
}, | |
purchased: { | |
type: "final" | |
} | |
} | |
} | |
}, | |
enterpriseUser: {} | |
}, | |
actions: { | |
show_download_button: (context, event) => { | |
console.log("start modal with license info..."); | |
}, | |
show_cart_button: (context, event) => { | |
console.log("start modal with license info..."); | |
} | |
}, | |
guards: { | |
hasPackForLicense: (context, event) => { | |
return event.hasPack; | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment