Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@PaulRBerg
Last active September 28, 2020 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulRBerg/4307883571cd95bee1dd992ecc567d23 to your computer and use it in GitHub Desktop.
Save PaulRBerg/4307883571cd95bee1dd992ecc567d23 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 setFundedContext = assign({
alice: 50,
bob: 50,
dai: 100,
});
const setFundedAndRewardedContext = assign({
alice: 50,
bob: 50,
dai: 0,
eth: 1,
});
const fetchMachine = Machine({
id: 'guarantorPool',
initial: 'pristine',
context: {
alice: 0,
bob: 0,
dai: 0,
eth: 0,
},
states: {
pristine: {
on: {
FUND: {
target: 'funded',
actions: setFundedContext,
},
},
},
funded: {
on: {
REWARD: {
target: 'fundedAndRewarded',
actions: setFundedAndRewardedContext,
},
},
},
fundedAndRewarded: {
on: {
EXIT: 'pristine',
WITHDRAW: 'funded',
},
},
},
},
{
actions: {
setFundedContext,
setFundedAndRewardedContext,
},
},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment