Search code examples
iosrx-swiftrx-cocoa

Why `NotificationCenter+Rx` is in RxCocoa not RxSwift


Since NotificationCenter is a part of Foundation. I expect it should be within RxSwift, not RxCocoa.

But why NotificationCenter+Rx is in RxCocoa? Any reason behind that?

In some of our project, we only use RxSwift without RxCocoa. If we use NotificationCenter.default.rx.notification, we will get the error Value of type 'Reactive<NotificationCenter>' has no member 'notification' because NotificationCenter+Rx is in RxCocoa only.


Solution

  • The easy answer is - RxSwift, RxJava etc are the platform-agnostic implementations of the ReactiveX.io standard, e.g. - Observables, Operators, Subjects, etc.

    While the platform-specific things are, well, platform-specific ;-) In our case, RxCocoa covers NotificationCenter which isn't relevant to other, non-Cocoa platforms.