Skip to content

Instantly share code, notes, and snippets.

@FeliciousX
Created October 12, 2020 04:27
Show Gist options
  • Save FeliciousX/ec73b84c301a25ac09d69bf77c126471 to your computer and use it in GitHub Desktop.
Save FeliciousX/ec73b84c301a25ac09d69bf77c126471 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": "PAYMENT",
"initial": "start",
"context": {
"adjustmentAmount": 0,
"applyCredit": false,
"creditAmount":10.05,
"paymentType": null
},
"states": {
"start": {
"entry":[{ "type": "helpers-init", "data": { "additional": true } }],
"on": {
"":"paymentOptions"
}
},
"paymentOptions": {
"on": {
"SELECT.CREDITCARD": { actions: "useCreditCard" },
"SELECT.SERVICECARD": { actions: "useServiceCard" },
"SELECT.REFILLCARD": { actions: "useRefillCard" },
"SELECT.CARDLESS": { actions: "useCardless" },
"submit": "processPayment"
}
},
"processPayment": {
"type":"final"
}
}
}, {
actions: {
"useCreditCard": assign({ paymentType: "CREDITCARD" }),
"useServiceCard": assign({ paymentType: "SERVICECARD" }),
"useRefillCard": assign({ paymentType: "REFILLCARD" }),
"useCardless": assign({ paymentType: "CARDLESS" }),
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment