Last active
November 2, 2020 18:48
-
-
Save shedali/aa3418da371abb4f2c729199c22a858e 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 fetchMachine = Machine({ | |
id: 'empty', | |
initial: 'empty', | |
context:{ | |
sufficientNotional: false, | |
sufficientMarginal: false, | |
instrumentCount: 0, | |
editingInstrument: false | |
}, | |
states: { | |
basket_empty:{ | |
}, | |
basket_pending:{ | |
on: { | |
} | |
}, | |
basket_notReady:{ | |
}, | |
basket_ready:{ | |
}, | |
basket_executed: { | |
}, | |
editable_basket:{ | |
}, | |
ready:{}, | |
empty:{ | |
} | |
} | |
}, { | |
guards: { | |
hasSufficientNotional: (context) => context.hasSufficientNotional === true, | |
hasSufficientMarginal: (context) => context.hasSufficientMarginal === true, | |
canPlaceOrder: context=>context.hasSufficientMarginal && context.hasSufficientNotional, | |
hasEmptyBasket: context=>context.hasEmptyBasket, | |
isEditingInstrument: context=>context.isEditingInstrument | |
}, | |
actions:{ | |
edit_instrument: (context, event)=>{ | |
return context.isEditingInstrument=true | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment