Last active
February 3, 2020 18:58
-
-
Save felippenardi/e9d06f8a2a39ad488ae7c1d30b2821bd 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 editingMachine = Machine({ | |
id: 'editingMachine', | |
initial: 'editing', | |
states: { | |
editing: { | |
id: 'editing', | |
on: { | |
SAVE: 'saving', | |
DISCARD: 'confirmingDiscard' | |
} | |
}, | |
confirmingDiscard: { | |
on: { | |
CONFIRM_DISCARD: '#viewing', | |
CANCEL_DISCARD: '#editing' | |
} | |
}, | |
saving: { | |
on: { | |
SUCCESS: 'viewing', | |
FAILURE: 'editing' | |
} | |
}, | |
viewing: { | |
id: 'viewing', | |
type: 'final' | |
} | |
} | |
}) | |
const contentMachine = Machine({ | |
id: 'content', | |
initial: 'draft', | |
context: { | |
}, | |
states: { | |
draft: { | |
id: 'draft', | |
initial: 'viewing', | |
states: { | |
viewing: { | |
on: { | |
OPEN_DRAFT: '#content.draft', | |
OPEN_LIVE: '#content.live', | |
EDIT: 'editing', | |
} | |
}, | |
editing: { | |
invoke: { | |
id: 'editingDraft', | |
src: editingMachine, | |
autoForward: true, | |
onDone: 'viewing' | |
}, | |
} | |
} | |
}, | |
live: { | |
initial: 'viewing', | |
states: { | |
viewing: { | |
on: { | |
OPEN_DRAFT: '#content.draft', | |
OPEN_LIVE: '#content.live', | |
EDIT: 'editing', | |
} | |
}, | |
editing: { | |
invoke: { | |
id: 'editingDraft', | |
src: editingMachine, | |
autoForward: true, | |
onDone: 'viewing' | |
}, | |
} | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment