Created
July 15, 2020 22:49
-
-
Save richartkeil/d40876a8abf1532cfd52c132923712fc 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 { | |
send(event: Event, user: User) { | |
const description = `New event ${event.name} occured at ${event.getTimestamp()}` | |
emailService.send({ to: user.email, subject: event.name, body: description }) | |
} | |
} | |
class NotificationHandler { | |
private mailer: EmailBroadcaster | |
constructor() { | |
this.mailer = new EmailBroadcaster() | |
} | |
public broadcast(event: Event, user: User) { | |
this.mailer.send(event, user) | |
} | |
} | |
function onAccountCreated(event: Event, user: User) { | |
const notifications = new NotificationHandler() | |
notifications.broadcast(event, user) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment