Skip to content

Instantly share code, notes, and snippets.

@matiasdim
Created December 7, 2020 14:48
Show Gist options
  • Save matiasdim/156a72c7de5c73a192875ff83ec2c5b1 to your computer and use it in GitHub Desktop.
Save matiasdim/156a72c7de5c73a192875ff83ec2c5b1 to your computer and use it in GitHub Desktop.
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