Skip to content

Instantly share code, notes, and snippets.

@Harrisonkamau
Last active April 30, 2020 17:09
Show Gist options
  • Save Harrisonkamau/e6b97406df015aa9dd7ad4d0fbdeb103 to your computer and use it in GitHub Desktop.
Save Harrisonkamau/e6b97406df015aa9dd7ad4d0fbdeb103 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const paymentMachine = Machine({
id: 'payment',
initial: 'plan',
states: {
plan: {
initial: '$10',
states: {
'$10': { on: { SWITCH_PLAN: '$20' } },
'$20': { on: { SWITCH_PLAN: '$10' } },
hist: { type: 'history' },
},
on: { NEXT: 'method' },
},
method: {
initial: 'cash',
states: {
cash: { on: { SWITCH_CARD: 'card' } },
card: { on: { SWITCH_CASH: 'cash' } },
hist: { type: 'history' },
},
on: { PLAN: 'plan.hist' },
on: { NEXT: 'review' },
},
review: {
on: { PREVIOUS: 'method.hist' },
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment