Skip to content

Instantly share code, notes, and snippets.

@tikotzky
Created November 13, 2019 16:26
Show Gist options
  • Save tikotzky/cf454cfb2a7e9c62e78d93b958be55a3 to your computer and use it in GitHub Desktop.
Save tikotzky/cf454cfb2a7e9c62e78d93b958be55a3 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine({
id: 'transaction',
initial: 'auth',
context: {
amountLeft: 10,
},
states: {
auth: {
on: {
CAPTURE: 'capture',
VOID: 'void',
ADJUST: 'adjust',
}
},
capture: {
on: {
CREDIT: {
target: 'credit',
cond: context => context.amountLeft > 0,
},
CHARGEBACK: 'chargedback',
}
},
chargedback: {
},
credit: {
on: {
PARTIAL: 'capture'
}
},
void: {
},
adjust: {
on :{
SUCCESS: 'auth',
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment