Skip to content

Instantly share code, notes, and snippets.

@felippenardi
Last active February 6, 2020 14:51
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 felippenardi/3e1146a94f365e23a9d4b5d2f9ed6a8c to your computer and use it in GitHub Desktop.
Save felippenardi/3e1146a94f365e23a9d4b5d2f9ed6a8c to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const editingMachine = Machine({
id: 'editing',
initial: 'editing',
states: {
editing: {
id: 'live',
on: {
SAVE_CHANGES: 'saving',
DISCARD_CHANGES: 'confirmingDiscard'
}
},
confirmingDiscard: {
on: {
CONFIRM_DISCARD: {
actions: 'discard'
},
CANCEL_DISCARD: '#editing'
}
},
saving: {
on: {
ON_SUCCESS: 'finish',
ON_CONFLICT: 'solvingConflict',
ON_FAILURE: 'editing'
}
},
solvingConflict: {
on: {
OVERRIDE: 'finish',
CANCEL: 'editing'
}
},
finish: {
id: 'finish',
type: 'final'
}
}
}, {
actions: {
discard: sendParent('DISCARD')
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment