1234567891011121314151617181920212223242526272829303132 |
- import Foundation
- extension Notification.Name {
-
- static let ReachabilityStateChanged = Notification.Name(
- rawValue: "ReachabilityStateChanged")
-
- static let HiddenStateChanged = Notification.Name(
- rawValue: "HiddenStateChanged")
-
- static let NoticePushed = Notification.Name(
- rawValue: "NoticePushed")
-
- static let WorkPushed = Notification.Name(
- rawValue: "WorkPushed")
- }
- extension Notification{
- typealias NotificationBlock = (Notification) -> Void
- static func registerNotification(name:NSNotification.Name, object:Any? = nil, queue:OperationQueue, block:@escaping NotificationBlock){
- NotificationCenter.default.addObserver(forName: name, object: object, queue: queue, using: block)
- }
-
- static func removeNotification(observer:Any){
- NotificationCenter.default.removeObserver(observer)
- }
-
- static func postNotification(name:NSNotification.Name, object:Any? = nil){
- NotificationCenter.default.post(name: name, object: object)
- }
- }
|