Created
January 25, 2017 23:04
-
-
Save BevanR/7e461650aab1c7dac20aae6a18a058fd to your computer and use it in GitHub Desktop.
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
class Button { | |
click() { | |
// TODO Animate the button. | |
} | |
} | |
class RedButton { | |
button = new Button() | |
style = { | |
color: 'red', | |
} | |
click() { | |
this.button.click() | |
} | |
} | |
class ConfirmButton { | |
button = new Button() | |
style = {} | |
click() { | |
if (confirm('Are you sure?')) { | |
this.button.click() | |
} | |
} | |
} | |
class RedConfirmButton { | |
confirmButton = new ConfirmButton() | |
redButton = new RedButton() | |
click() { | |
// Use ConfirmButton's behaviour. | |
this.confirmButton.click() | |
} | |
get style() { | |
// But RedButton's style. | |
return this.redButton.style | |
} | |
} | |
type AnyButton = RedButton | Button | ConfirmButton | RedConfirmButton |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment