Skip to content

Instantly share code, notes, and snippets.

@komkanit
Last active July 9, 2020 07:26
Show Gist options
  • Save komkanit/5b9acc814709d6fdd31b51dcb949a2be to your computer and use it in GitHub Desktop.
Save komkanit/5b9acc814709d6fdd31b51dcb949a2be 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: 'OddTransferRequest',
initial: 'receive',
context: {
retries: 0
},
states: {
receive: {
on: {
amcTransactionCreated: 'oddTransferCreated',
hold: 'onHold',
canceled: 'canceled'
}
},
onHold: {
on: {
unhold: 'receive',
canceled: 'canceled'
}
},
oddTransferCreated: {
on: {
amcTransactionSubmited: 'oddTransferProcessing',
amcTransactionCanceled: 'receive',
}
},
oddTransferProcessing: {
on: {
amcTransactionSucceed: 'oddTransferSuccess',
amcTransactionFailed: 'oddTransferFailed',
}
},
oddTransferFailed: {
on: {
cancel: 'canceled',
retry: 'receive'
}
},
oddTransferSuccess: {
on: {
amcTransactionCreated: 'amcBuyCreated'
}
},
amcBuyCreated: {
on: {
amcTransactionSubmited: 'amcBuyProcessing',
amcTransactionCanceled: 'oddTransferSuccess',
}
},
amcBuyProcessing: {
on: {
amcTransactionSucceed: 'amcBuySuccess',
amcTransactionFailed: 'amcBuyFailed',
}
},
amcBuyFailed: {
on: {
cancel: 'canceled',
retry: 'oddTransferCreated'
}
},
amcBuySuccess: {
type: 'final'
},
canceled: {},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment