File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed
Swift_Play/Module/RxSwift Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -465,9 +465,36 @@ extension RxSwiftViewController{
465
465
466
466
DispatchQueue . main. asyncAfter ( deadline: . now( ) + 3 ) {
467
467
Observable . just ( " Hello Binder " )
468
- . bind ( to: self . contentLabel. rx. text) // self.contentLabel.rx.text是RX内置的Binder , 这版RxSwift可能调整了,和中文文档解释的不一样
468
+ . bind ( to: self . contentLabel. rx. text)
469
469
}
470
470
471
+ /**
472
+ self.contentLabel.rx实际返回了Reactive(self)
473
+ Reactive实现了 @dynamicMemberLookup,通过keyPath获取到
474
+ Binder(self.base) { base, value in base[keyPath: keyPath] = value} 这个Binder
475
+
476
+ @dynamicMemberLookup
477
+ public struct Reactive<Base> {
478
+ /// Base object to extend.
479
+ public let base: Base
480
+
481
+ /// Creates extensions with base object.
482
+ ///
483
+ /// - parameter base: Base object.
484
+ public init(_ base: Base) {
485
+ self.base = base
486
+ }
487
+
488
+ /// Automatically synthesized binder for a key path between the reactive
489
+ /// base and one of its properties
490
+ public subscript<Property>(dynamicMember keyPath: ReferenceWritableKeyPath<Base, Property>) -> Binder<Property> where Base: AnyObject {
491
+ Binder(self.base) { base, value in
492
+ base[keyPath: keyPath] = value
493
+ }
494
+ }
495
+ }
496
+
497
+ */
471
498
472
499
// self.startBtn.rx.isEnabled
473
500
}
You can’t perform that action at this time.
0 commit comments