Created
November 2, 2020 16:19
-
-
Save sventschui/e2db0624ca9c0f8bf5894a4b73def643 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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
// 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