Last active
May 4, 2021 01:21
-
-
Save lasergoat/52734752c6f55a71f0545820bbac6585 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) | |
const fetchMachine = Machine({ | |
id: 'splitter', | |
initial: 'idle', | |
context: { | |
splits: [{amount: 100.00}] | |
}, | |
states: { | |
editing: { | |
on: { | |
FINALIZE: 'saving', | |
DELETE: 'editing', | |
SPLITAGAIN: { | |
target: 'editing', | |
actions: assign({ | |
splits: (context, event) => [...context.splits, {amount: 0}] | |
}) | |
} | |
} | |
}, | |
loading: { | |
on: { | |
RESOLVE: 'editing', | |
REJECT: 'idle' | |
} | |
}, | |
saving: { | |
on: { | |
RESOLVE: 'idle', | |
REJECT: 'editing' | |
} | |
}, | |
idle: { | |
on: { | |
EDITCLICK: 'loading' | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment