Created
December 7, 2020 14:48
-
-
Save matiasdim/156a72c7de5c73a192875ff83ec2c5b1 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
protocol Receiver { | |
func receiveNotification() | |
} | |
class Notifier { | |
private var notificationReceiver: Receiver | |
init(receiver: Receiver) { | |
self.notificationReceiver = receiver | |
} | |
func somethingHappened() { | |
notificationReceiver.receiveNotification() | |
} | |
} | |
class NotificationReceiver: Receiver { | |
func receiveNotification() { | |
// Do something | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment