Skip to content

Instantly share code, notes, and snippets.

@richartkeil
Last active June 3, 2020 15:43
Show Gist options
  • Save richartkeil/c590e519ba2efac148a0a68b2cb7ac5b to your computer and use it in GitHub Desktop.
Save richartkeil/c590e519ba2efac148a0a68b2cb7ac5b to your computer and use it in GitHub Desktop.
class EmailBroadcaster {
broadcast(event: {}, user: SubscribedUser) {
// Send email with subscription information
// and event details to user.
}
}
class AnonymousEmailBroadcaster extends EmailBroadcaster {
broadcast(event: {}, user: User) {
// Send email with only event details to user.
}
}
function onAccountCreated(event: {}) {
const user = getCurrentSubscribedUser(); // returns type SubscribedUser
(new EmailBroadcaster).broadcast(event, user);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment