Skip to content

Instantly share code, notes, and snippets.

@shedali
Last active November 2, 2020 18:48
Show Gist options
  • Save shedali/aa3418da371abb4f2c729199c22a858e to your computer and use it in GitHub Desktop.
Save shedali/aa3418da371abb4f2c729199c22a858e to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
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