Skip to content

Instantly share code, notes, and snippets.

@wspringer
Last active May 7, 2020 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wspringer/89d54f0c5589a6330ec0190545526654 to your computer and use it in GitHub Desktop.
Save wspringer/89d54f0c5589a6330ec0190545526654 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const ConsumerTransferFlowMachine = Machine(
{
id: 'ConsumerTransfer',
initial: 'in_progress',
context: {
actionDate: 3
},
states: {
in_progress: {
on: {
TerminationNotification: [{
target: 'terminated',
cond: 'terminationInTime',
actions: 'TransactionAcknowledgement'
}, {
target: 'in_progress',
actions: 'TransactionAcknowledgement'
}],
},
after: {
4000: 'completed',
},
},
terminated: {
type: 'final',
entry: ['Terminated']
},
completed: {
type: 'final',
entry: ['ChangeCompleted']
},
},
},
{
guards: {
terminationInTime: (context, event) => {
return context.actionDate > 3;
}
},
actions: {
ChangeCompleted: () => {
console.info('ChangeCompleted')
},
TransactionAcknowledgement: () => {
console.info('TransactionAcknowledgement')
},
Terminated: () => {
console.info('Terminated');
}
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment