Last active
November 29, 2020 18:34
-
-
Save alveshelio/b6763d8c1e63ae2e700505326949bfe1 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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