Skip to content

Instantly share code, notes, and snippets.

@eschaefer
Last active March 5, 2020 16:30
Show Gist options
  • Save eschaefer/668c6880eef24431b00b59b0bdca29f8 to your computer and use it in GitHub Desktop.
Save eschaefer/668c6880eef24431b00b59b0bdca29f8 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 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