Skip to content

Instantly share code, notes, and snippets.

@kelchm
Last active May 8, 2020 21:57
Show Gist options
  • Save kelchm/98746b6910ebc0148ea01f6d2557d5bd to your computer and use it in GitHub Desktop.
Save kelchm/98746b6910ebc0148ea01f6d2557d5bd to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const hasDelinquencies = () => true;
const hasInsufficientFunds = () => false;
const financialPlanMachine = Machine({
id: 'financialPlan',
initial: 'checkingForDisqualification',
states: {
checkingForDisqualification: {
on: {
FINISH_DISQUALIFICATION: [
{
target: 'disqualified.delinquencyThresholdExceeded',
cond: hasDelinquencies,
},
{
target: 'disqualified.insufficientFunds',
cond: hasInsufficientFunds,
},
{
target: 'displayPlan',
},
],
},
},
disqualified: {
type: 'parallel',
states: {
delinquencyThresholdExceeded: {},
insufficientFunds: {}
},
on: {
USER_INPUT: 'checkingForDisqualification',
},
},
displayPlan: {
on: {
USER_INPUT: 'checkingForDisqualification',
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment