Skip to content

Instantly share code, notes, and snippets.

@richartkeil
Last active June 3, 2020 15:43
Show Gist options
  • Save richartkeil/bc283330fc364abcf81a7dfa3713e940 to your computer and use it in GitHub Desktop.
Save richartkeil/bc283330fc364abcf81a7dfa3713e940 to your computer and use it in GitHub Desktop.
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