Skip to content

Instantly share code, notes, and snippets.

@lasergoat
Last active May 4, 2021 01:21
Show Gist options
  • Save lasergoat/52734752c6f55a71f0545820bbac6585 to your computer and use it in GitHub Desktop.
Save lasergoat/52734752c6f55a71f0545820bbac6585 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: '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