Last active
March 12, 2020 21:55
-
-
Save andrewgordstewart/ae70da57a5e00c194ec1634b5280a1c2 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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 config = { | |
key: 'ledger-funding', | |
initial: 'acquiringLock', | |
states: { | |
acquiringLock: { | |
invoke: {src: 'acquireLock', onDone: 'fundingTarget'}, | |
exit: {type: 'xstate.assign', assignment: {lock: (_, event) => event.data}} | |
}, | |
fundingTarget: { | |
initial: 'getTargetOutcome', | |
states: { | |
getTargetOutcome: { | |
invoke: { | |
src: 'getTargetOutcome', | |
onDone: 'supportState', | |
onError: {target: '#ledger-funding.failure'} | |
} | |
}, | |
supportState: { | |
invoke: { | |
id: undefined, | |
src: 'supportState', | |
data: (_, {data}) => data, | |
onDone: 'done', | |
onError: {target: '#ledger-funding.failure'} | |
} | |
}, | |
done: {type: 'final'} | |
}, | |
onDone: 'releasingLock' | |
}, | |
failure: { | |
entry: [ | |
{type: 'xstate.assign', assignment: {error: (_, event) => event.data.message}}, | |
'escalateError' | |
], | |
invoke: {src: 'releaseLock'} | |
}, | |
releasingLock: { | |
invoke: {src: 'releaseLock', onDone: 'updatingFunding', onError: 'updatingFunding'} | |
}, | |
updatingFunding: {invoke: {src: 'updateFunding', onDone: 'success'}}, | |
success: {type: 'final'} | |
} | |
}; | |
const guards = {}; | |
const customActions = {}; | |
const machine = Machine(config, {guards, actions: customActions}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment