Create postDisplayNameDidChangeNotification, so that a DisplayNameProvider can post a Notification when its name changes.

This commit is contained in:
Brent Simmons 2018-01-22 21:58:53 -08:00
parent 6ec2f72443
commit 786138d6e7

View File

@ -8,8 +8,21 @@
import Foundation
extension Notification.Name {
public static let DisplayNameDidChange = Notification.Name("DisplayNameDidChange")
}
public protocol DisplayNameProvider {
var nameForDisplay: String { get }
}
public extension DisplayNameProvider {
func postDisplayNameDidChangeNotification() {
NotificationCenter.default.post(name: .DisplayNameDidChange, object: self, userInfo: nil)
}
}