diff --git a/src/NotificationListener.swift b/src/NotificationListener.swift index af6ad89..55fff0a 100755 --- a/src/NotificationListener.swift +++ b/src/NotificationListener.swift @@ -21,12 +21,12 @@ public class NotificationListener : Listener { if self._targetID != getHash(target) { return } - } else { - return - } - } + } else { + return + } + } - self._trigger(notif.userInfo) + self._trigger(notif) }) // Add self to global cache. @@ -49,10 +49,10 @@ public class NotificationListener : Listener { NotificationListenerCache[self.name] = targets.nilIfEmpty } - init (_ name: Notification.Name, _ target: AnyObject!, _ once: Bool, _ handler: @escaping (NSDictionary) -> Void) { + init (_ name: Notification.Name, _ target: AnyObject!, _ once: Bool, _ handler: @escaping (Notification) -> Void) { self.name = name super.init(target, once) { - handler(($0 as? NSDictionary) ?? [:]) + handler($0 as! Notification) } } } diff --git a/src/Notifier.swift b/src/Notifier.swift index f13f512..11855fa 100755 --- a/src/Notifier.swift +++ b/src/Notifier.swift @@ -13,21 +13,21 @@ public class Notifier { self.name = name } - public func on (_ handler: @escaping (NSDictionary) -> Void) -> NotificationListener { + public func on (_ handler: @escaping (Notification) -> Void) -> NotificationListener { return NotificationListener(name, nil, false, handler) } - public func on (_ target: AnyObject!, _ handler: @escaping (NSDictionary) -> Void) -> NotificationListener { + public func on (_ target: AnyObject!, _ handler: @escaping (Notification) -> Void) -> NotificationListener { return NotificationListener(name, target, false, handler) } @discardableResult - public func once (_ handler: @escaping (NSDictionary) -> Void) -> NotificationListener { + public func once (_ handler: @escaping (Notification) -> Void) -> NotificationListener { return NotificationListener(name, nil, true, handler) } @discardableResult - public func once (_ target: AnyObject!, _ handler: @escaping (NSDictionary) -> Void) -> NotificationListener { + public func once (_ target: AnyObject!, _ handler: @escaping (Notification) -> Void) -> NotificationListener { return NotificationListener(name, target, true, handler) }