Skip to content

Instantly share code, notes, and snippets.

@horacioh
Last active July 9, 2021 09:48
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 horacioh/e2a46aa15212a3e15637d3b38e51053a to your computer and use it in GitHub Desktop.
Save horacioh/e2a46aa15212a3e15637d3b38e51053a 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 sidepanelMachine = Machine({
id: 'sidepanel',
initial: 'disabled',
states: {
disabled: {
on: {
SIDEPANEL_ENABLE: {
target: 'enabled.hist'
}
}
},
enabled: {
id: 'enabled',
on: {
SIDEPANEL_DISABLE: {
target: 'disabled'
},
SIDEPANEL_ADD_ITEM: {
actions: 'sidepanelAddItem',
target: '.opened'
},
SIDEPANEL_REMOVE_ITEM: {
actions: 'sidepanelRemoveItem',
}
},
initial: 'closed',
states: {
closed: {
on: {
SIDEPANEL_OPEN: {
target: 'opened'
}
}
},
opened: {
on: {
SIDEPANEL_CLOSE: {
target: 'closed'
}
}
},
hist: {
type: 'history',
history: 'shallow'
},
}
},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment