Skip to content

Instantly share code, notes, and snippets.

@andrewgordstewart
Created March 10, 2020 14:57
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 andrewgordstewart/cf7c6ef762ee62489895ed7e313b718a to your computer and use it in GitHub Desktop.
Save andrewgordstewart/cf7c6ef762ee62489895ed7e313b718a to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const config = {
key: 'create-and-fund',
initial: 'preFundSetup',
on: {'xstate.error': {target: 'failure'}},
states: {
preFundSetup: {
initial: 'getPreFundSetup',
states: {
getPreFundSetup: {
invoke: {src: 'getPreFundSetup', onDone: 'supportState', onError: undefined}
},
supportState: {
invoke: {id: undefined, src: 'supportState', data: (_, {data}) => data, onDone: 'done'}
},
done: {type: 'final'}
},
onDone: 'funding'
},
funding: {
initial: 'chooseFundingStrategy',
states: {
chooseFundingStrategy: {
invoke: {src: 'determineFunding'},
on: {UseVirtualFunding: 'virtual', UseDirectFunding: 'direct'}
},
direct: {
initial: 'depositing',
states: {
depositing: {
initial: 'getDepositingInfo',
states: {
getDepositingInfo: {
invoke: {src: 'getDepositingInfo', onDone: 'depositing', onError: undefined}
},
depositing: {
invoke: {
id: undefined,
src: 'depositing',
data: (_, {data}) => data,
onDone: 'done'
}
},
done: {type: 'final'}
},
onDone: 'updateFunding'
},
updateFunding: {invoke: {src: 'setFundingToDirect', onDone: 'done'}},
done: {type: 'final'}
},
onDone: 'done'
},
virtual: {
initial: 'running',
entry: 'triggerObjective',
states: {
running: {
initial: 'getObjective',
states: {
getObjective: {
invoke: {src: 'getObjective', onDone: 'virtualFunding', onError: undefined}
},
virtualFunding: {
invoke: {
id: undefined,
src: 'virtualFunding',
data: (_, {data}) => data,
onDone: 'done'
}
},
done: {type: 'final'}
},
onDone: 'updateFunding'
},
updateFunding: {invoke: {src: 'setFundingToVirtual', onDone: 'done'}},
done: {type: 'final'}
},
onDone: 'done'
},
done: {type: 'final'}
},
onDone: 'postFundSetup'
},
postFundSetup: {
initial: 'getPostFundSetup',
states: {
getPostFundSetup: {
invoke: {src: 'getPostFundSetup', onDone: 'supportState', onError: undefined}
},
supportState: {
invoke: {id: undefined, src: 'supportState', data: (_, {data}) => data, onDone: 'done'}
},
done: {type: 'final'}
},
onDone: 'success'
},
success: {type: 'final'},
failure: {}
}
};
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