
.rx的实现原理
关联类型。
主要实现ReactiveCompatible协议,实现了这个协议的都会有rx。万物皆rx
/// Extend NSObject with `rx` proxy.
extension ReactiveCompatible {
/// Reactive extensions.
public static var rx: Reactive<Self>.Type {
get {
return Reactive<Self>.self
}
set {
// this enables using Reactive to "mutate" base type
}
}
/// Reactive extensions.
public var rx: Reactive<Self> {
get {
return Reactive(self)
}
set {
// this enables using Reactive to "mutate" base object
}
}
}
extension NSObject: ReactiveCompatible { }
网友评论