Skip to content

Instantly share code, notes, and snippets.

@sventschui
Created November 2, 2020 16:19
Show Gist options
  • Save sventschui/e2db0624ca9c0f8bf5894a4b73def643 to your computer and use it in GitHub Desktop.
Save sventschui/e2db0624ca9c0f8bf5894a4b73def643 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)
function isIban() {
}
function accountNoDidChange() {
}
const fetchMachine = Machine({
id: 'accountNoIban',
initial: 'doWonder',
context: {
},
states: {
doWonder: {
on: {
'': [
{
target: 'iban',
cond: isIban
},
{ target: 'accountNo' }
]
}
},
accountNo: {
on: {
TYPE: 'doWonder'
},
},
iban: {
on: {
TYPE: 'doWonder'
},
initial: 'init',
states: {
init: {
on: {
'': [{
target: 'loading',
cond: accountNoDidChange
}, {
target: 'loaded'
}]
}
},
loading: {
invoke: {
src: (callback, onReceive) => {
// do fetch bank-info by accountNo
return () => { /* cancel XHR */ };
},
onDone: 'loaded',
onError: 'error'
},
},
loaded: {},
error: {},
}
},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment