Skip to content

Instantly share code, notes, and snippets.

@felippenardi
Created February 1, 2020 22:53
Show Gist options
  • Save felippenardi/944ed8f8db55e3abc1e14d6fa3048c6c to your computer and use it in GitHub Desktop.
Save felippenardi/944ed8f8db55e3abc1e14d6fa3048c6c 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 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