Skip to content

Instantly share code, notes, and snippets.

@christianhg
Last active January 27, 2020 10:11
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 christianhg/1710361a1c60c4d462c4723ab88a5c00 to your computer and use it in GitHub Desktop.
Save christianhg/1710361a1c60c4d462c4723ab88a5c00 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: 'read-only-overlay',
type: 'parallel',
context: {
overlay: {
id: '',
readOnly: false,
readOnlyMessage: undefined,
userWarning: undefined
}
},
states: {
inheritance: {
initial: 'branched',
states: {
branched: {
initial: 'pristine',
on: {
INHERITANCE_INSTANTIATED: 'inherited'
},
states: {
pristine: {
on: {DIRTY: 'dirty'}
},
dirty: {
on: {
PRISTINE: 'pristine'
}
}
}
},
inherited: {
initial: 'idle',
on: {
INHERITANCE_BROKEN: 'branched',
},
states: {
idle: {
on: {
DIRTY_MASTER: 'dirtyMaster'
}
},
dirtyMaster: {
on: {
CLEAN_MASTER: 'idle'
}
}
}
}
}
},
print: {
initial: 'idle',
states: {
idle: {
on: {
OVERLAY_CHANGED: {
target: 'branched',
cond: 'overlayIsReadOnly'
},
}
},
unbranched: {
on: {
BRANCHED: 'branched'
}
},
branched: {
on: {
RELEASED: 'released',
UNBRANCHED: 'unbranched'
}
},
released: {
}
}
},
warning: {
initial: 'unwarned',
states: {
unwarned: {
on: {
OVERLAY_CHANGED: {
target: 'warned',
in: 'inheritance.branched.dirty'
}
}
},
warned: {
onEntry: ['warnUser']
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment