Last active
March 20, 2020 04:53
-
-
Save amite/acd815fbc49f2c5946d2c688425187be to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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" | |
} | |
}; | |
const unlit = { | |
on: { | |
BREAK: { | |
target: "broken", | |
actions: ['logBroken'] | |
}, | |
TOGGLE: "lit" | |
} | |
}; | |
const broken = { | |
type: "final" | |
}; | |
const states = { unlit,lit, broken }; | |
const initial = "unlit"; | |
const config = { | |
id: "lightBulb", | |
initial, | |
states, | |
strict: true | |
}; | |
const lightBulbMachine = Machine(config, { | |
actions: { | |
logBroken: () => console.log('I am broken') | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment