Last active
July 17, 2018 03:02
-
-
Save ShMcK/c4527f4a3549ed3434abe2d0bce68a1d to your computer and use it in GitHub Desktop.
VisualizingState: Walkman State Machine Guard 2
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
class Walkman extends React.Component { | |
transition = (event) => { | |
const preventTapeJam = /* ... */ | |
const shouldEject = event === 'STOP' && this.state.current === 'Stopped' | |
if (!preventTapeJam) { | |
/* … */ | |
} else if (shouldEject) { | |
this.setState({ current: events.EJECT }) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment