Last active
June 3, 2020 15:43
-
-
Save richartkeil/bc283330fc364abcf81a7dfa3713e940 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 EmailBroadcaster { | |
broadcast(event: Event, user: User) { | |
// Send email with event details to user. | |
} | |
} | |
class SubscriptionEmailBroadcaster extends EmailBroadcaster { | |
broadcast(event: Event, user: SubscribedUser) { | |
// Send email with additional subscription information | |
// and event details to user. | |
} | |
} | |
function onAccountCreated(event: Event}) { | |
const user = getCurrentUser(); // returns type User or SubscribedUser | |
(new EmailBroadcaster).broadcast(event, user); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment