Skip to content

Instantly share code, notes, and snippets.

@darrenbutcher
Last active December 14, 2020 16:16
Show Gist options
  • Save darrenbutcher/d191a9aa8c44230eec77e7775b0e2769 to your computer and use it in GitHub Desktop.
Save darrenbutcher/d191a9aa8c44230eec77e7775b0e2769 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const lampMachine = Machine({
id: 'lamp',
initial: 'unplugged',
states: {
unplugged: {
on: {
PLUG_IN: 'plugged.hist',
BREAK: '#broken'
}
},
plugged: {
id: 'plugged',
type: "parallel",
states: {
radio: {
initial: 'off',
states: {
on: {
on: {
RADIO_SWITCH: 'off'
}
},
off: {
on: {
RADIO_SWITCH: 'on'
}
}
}
},
light: {
initial: 'off',
states: {
on: {
on: {
LIGHT_SWITCH: 'off'
}
},
off: {
on: {
LIGHT_SWITCH: 'on'
}
}
}
},
hist: {
type: 'history',
history: 'deep',
}
},
on: {
BREAK: '#broken',
UNPLUG: 'unplugged'
}
},
broken: {
id: 'broken',
type: 'final'
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment