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
| DrawerOpen* | |
| loadTape -> HasTape | |
| closeDrawer -> NoTape | |
| DrawerClosed | |
| eject -> DrawerOpen | |
| NoTape | |
| HasTape* |
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
| Ejected | |
| STOP -> Stopped | |
| Stopped* | |
| STOP -> Ejected | |
| PLAY -> Playing | |
| REWIND -> Rewinding | |
| FAST_FORWARD -> FastForwarding | |
| Active | |
| STOP -> Stopped | |
| PLAY -> Stopped |
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
| None* | |
| BLOCK_SELECT -> BlockEditing | |
| TOOL_DRAW_BLOCK -> BlockDrawing | |
| TOOL_UPLOAD_SHAPES -> UploadingShapes | |
| TOOL_RESOURCE_VIEW -> ResourceView | |
| BlockDrawing | |
| BLOCK_SHAPE_COMPLETE -> BlockEditing | |
| CANCEL_DRAWING -> None | |
| BlockEditing |
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
| type States = { | |
| mode: 'loading' | 'loaded' | 'error', | |
| data: any, | |
| } | |
| class DataLoader extends React.Component<{}, States> { | |
| state = { | |
| mode: 'loading', // state | |
| data: {}, // data | |
| } |
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
| type States = 'loading' | 'loaded' | 'error' | |
| type Data = any | |
| class SomeComponent extends StateComponent<{}, States, Data> { | |
| state = 'loading' | |
| data = {} | |
| } |
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 events = { | |
| STOP: 'Stopped', | |
| PLAY: 'Playing', | |
| } | |
| class Walkman extends React.Component { | |
| state = { | |
| current: events.STOP, | |
| } | |
| transition = (event) => { |
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 events = { | |
| STOP: 'Stopped', | |
| PLAY: 'Playing', | |
| REWIND: 'Rewinding', | |
| FASTFORWARD: 'FastForwarding', | |
| } | |
| class Walkman extends React.Component { | |
| state = { | |
| current: events.STOP, |
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 events = { | |
| STOP: 'Stopped', | |
| PLAY: 'Playing', | |
| REWIND: 'Rewinding', | |
| FASTFORWARD: 'FastForwarding', | |
| } | |
| class Walkman extends React.Component { | |
| transition = (target) => { | |
| const preventTapeJam = |
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 }) | |
| } |
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 events = { | |
| STOP: 'Stopped', | |
| PLAY: 'Playing' | |
| } |