为什么 `NotificationCenter+Rx` 在 RxCocoa 而不是 RxSwift

Why `NotificationCenter+Rx` is in RxCocoa not RxSwift

NotificationCenter is a part of Foundation。我希望它应该在 RxSwift 中,而不是在 RxCocoa 中。

但是为什么 NotificationCenter+Rx 在 RxCocoa 中?这背后有什么原因吗?

在我们的一些项目中,我们只使用 RxSwift 而没有使用 RxCocoa。如果我们使用 NotificationCenter.default.rx.notification,我们将得到错误 Value of type 'Reactive<NotificationCenter>' has no member 'notification' 因为 NotificationCenter+Rx 仅在 RxCocoa 中。

简单的答案是 - RxSwift、RxJava 等是 ReactiveX.io 标准的平台无关实现,例如- Observables、Operators、Subjects 等

虽然平台-特定的东西是特定于平台的;-)在我们的例子中,RxCocoa涵盖了与其他不相关的NotificationCenter , 非Cocoa 平台。