Skip to content

Instantly share code, notes, and snippets.

@alveshelio
Last active November 29, 2020 18:34
Show Gist options
  • Save alveshelio/b6763d8c1e63ae2e700505326949bfe1 to your computer and use it in GitHub Desktop.
Save alveshelio/b6763d8c1e63ae2e700505326949bfe1 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const lit = {
on: {
BREAK: 'broken',
TOGGLE: 'unlit',
CHNAGE_COLOR: {
actions: ['changeColor']
}
}
}
const unlit = {
on: {
BREAK: 'broken',
TOGGLE: 'lit'
}
}
const broken = {}
const states = { lit, unlit, broken }
const initial = 'unlit'
const config = {
id: 'multiColoredBulb',
context: {
color: '#fff'
},
initial,
states,
strict: true,
devTools: true,
}
const lightBulbMachine = Machine(config, {
actions: {
changeColor: assign((context, { color }) => ({
color
}))
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment