Created
February 1, 2020 22:53
-
-
Save felippenardi/944ed8f8db55e3abc1e14d6fa3048c6c 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 contentEditorMachine = Machine({ | |
id: 'editor', | |
initial: 'unknown', | |
context: { | |
hasLive: false, | |
hasDraft: true | |
}, | |
states: { | |
'unknown': { | |
on: { | |
'': [ | |
{ target: 'editing', cond: 'hasDraft' }, | |
{ target: 'viewing', cond: 'hasLive' }, | |
]} | |
}, | |
viewing: { | |
on: { | |
EDIT: 'editing' | |
} | |
}, | |
editing: { | |
on: { | |
SAVE: 'saved' | |
} | |
}, | |
saved: { | |
on: { | |
PUBLISH: 'published', | |
} | |
}, | |
published: { | |
type: 'final' | |
}, | |
} | |
}, { | |
guards: { | |
hasLive: ctx => ctx.hasLive, | |
hasDraft: ctx => ctx.hasDraft | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment