[英]Why `NotificationCenter+Rx` is in RxCocoa not RxSwift
Since NotificationCenter is a part of Foundation . 由于NotificationCenter是Foundation的一部分。 I expect it should be within RxSwift, not RxCocoa.
我希望它应该在RxSwift而不是RxCocoa中。
But why NotificationCenter+Rx is in RxCocoa? 但是,为什么NotificationCenter + Rx包含在RxCocoa中? Any reason behind that?
有什么原因吗?
In some of our project, we only use RxSwift without RxCocoa. 在我们的某些项目中,我们仅使用RxSwift而不使用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. 如果我们使用
NotificationCenter.default.rx.notification
,则会收到错误消息Value of type 'Reactive<NotificationCenter>' has no member 'notification'
因为NotificationCenter + Rx仅在RxCocoa中。
The easy answer is - RxSwift, RxJava etc are the platform-agnostic implementations of the ReactiveX.io standard, eg - Observables, Operators, Subjects, etc. 简单的答案是-RxSwift,RxJava等是ReactiveX.io标准的与平台无关的实现,例如-Observable,Operator,Subject等。
While the platform- specific things are, well, platform-specific ;-) In our case, RxCocoa covers NotificationCenter which isn't relevant to other, non-Cocoa platforms. 虽然平台特定的东西是平台特定的;-)在我们的案例中,RxCocoa涵盖了NotificationCenter,它与其他非Cocoa平台无关。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.