Last active
May 7, 2020 12:45
-
-
Save wspringer/89d54f0c5589a6330ec0190545526654 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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
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