Last active
May 17, 2020 12:29
-
-
Save mouselangelo/947ffaef2372d5a5df019d93a5be380d 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 maschine = Machine({ | |
key: "subscription", | |
initial: "free", | |
context: { provider: undefined }, | |
states: { | |
free: { | |
on: { START: "subscribed" }, | |
}, | |
expired: { | |
initial: "churned", | |
states: { | |
churned: { | |
on: { | |
RESTART: "#subscription.subscribed", | |
WIN_BACK: "#subscription.subscribed", | |
}, | |
}, | |
inBillingRetry: { | |
on: { | |
RECOVER: "#subscription.subscribed", | |
RESTART: "#subscription.subscribed", | |
WIN_BACK: "#subscription.subscribed", | |
FAILED_TO_RECOVER: "churned", | |
}, | |
}, | |
}, | |
}, | |
subscribed: { | |
initial: "autoRenewing", | |
states: { | |
autoRenewing: { | |
on: { | |
RENEW: "autoRenewing", | |
CANCEL: "expiring", | |
REFUND: "#subscription.expired", | |
BILLING_ERROR: "inGracePeriod", | |
}, | |
}, | |
expiring: { | |
on: { | |
EXPIRE: "#subscription.expired", | |
RETAIN: "autoRenewing", | |
RESTART: "autoRenewing", | |
}, | |
}, | |
inGracePeriod: { | |
on: { | |
RECOVER: "autoRenewing", | |
GRACE_PERIOD_END: "#subscription.expired.inBillingRetry", | |
}, | |
}, | |
}, | |
}, | |
}, | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment