
RX實現(xiàn).jpg
.rx的實現(xiàn)原理
關聯(lián)類型。
主要實現(xiàn)ReactiveCompatible協(xié)議,實現(xiàn)了這個協(xié)議的都會有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 { }