Skip to content

Instantly share code, notes, and snippets.

@pablolmiranda
Created July 12, 2020 23:51
Show Gist options
  • Save pablolmiranda/e06ad349ecb54dde6dd8c4bf6d90be21 to your computer and use it in GitHub Desktop.
Save pablolmiranda/e06ad349ecb54dde6dd8c4bf6d90be21 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: 'editor-modal',
initial: 'idle',
states: {
idle: {
on: {
typing: 'dirty',
},
},
dirty: {
on: {
save: 'saving',
close: 'modal',
},
},
saving: {
on: {
done: 'saved',
error: 'dirty',
},
},
saved: {
on: {
typing: 'dirty',
},
},
modal: {
id: 'modal',
initial: 'open',
states: {
open: {
on: { yes: '#editor-modal.saving', no: 'close', cancel: 'close' },
},
close: {
on: {
'': '#editor-modal.dirty',
},
},
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment