Created
June 12, 2020 15:44
-
-
Save richartkeil/698c0f50df67215c0bec9c6ca84320ce 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
interface CanBroadcast { | |
send(event: Event, user: User) | |
} | |
interface CanTrackReads { | |
trackReads(track: boolean); | |
} | |
class EmailBroadcaster implements CanBroadcast, CanTrackReads { | |
send(event: Event, user: User) { | |
emailService.send({ to: user.email, subject: event.name }) | |
} | |
trackReads(track: boolean) { | |
emailService.setConfig({ trackOpens: track ? "always" : "never" }) | |
} | |
} | |
class PushBroadcaster implements CanBroadcast { | |
send(event: Event, user: User) { | |
const description = `New event ${event.name} occured!` | |
pushService.push({ token: user.pushKey, body: description }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment