NotificationCenter.swift 1.2 KB

12345678910111213141516171819202122232425262728
  1. import Combine
  2. import Foundation
  3. protocol NotificationCenter {
  4. func addObserver(_ observer: Any, selector aSelector: Selector, name aName: NSNotification.Name?, object anObject: Any?)
  5. func post(_ notification: Notification)
  6. func post(name aName: NSNotification.Name, object anObject: Any?)
  7. func post(name aName: NSNotification.Name, object anObject: Any?, userInfo aUserInfo: [AnyHashable: Any]?)
  8. func removeObserver(_ observer: Any)
  9. func removeObserver(_ observer: Any, name aName: NSNotification.Name?, object anObject: Any?)
  10. @discardableResult func addObserver(
  11. forName name: NSNotification.Name?,
  12. object obj: Any?,
  13. queue: OperationQueue?,
  14. using block: @escaping (Notification) -> Void
  15. ) -> NSObjectProtocol
  16. func publisher(for name: Notification.Name, object: AnyObject?) -> Foundation.NotificationCenter.Publisher
  17. func publisher(for name: Notification.Name) -> Foundation.NotificationCenter.Publisher
  18. }
  19. extension Foundation.NotificationCenter: NotificationCenter {
  20. func publisher(for name: Notification.Name) -> Foundation.NotificationCenter.Publisher {
  21. publisher(for: name, object: nil)
  22. }
  23. }