/ / sequence of the self. The person. The rx. ObserveWeakly (String. The self,"name")
            .subscribe(onNext: { (change) in
                print("ObserveWeakly subscribed to KVO:\(String(describing: change))")
            })
            .disposed(by: disposeBag)
Copy the code

ObserveWeakly Called observeWeaklyKeyPathFor from the observeWeakly method

observable

propertyAttributes
isWeak

propertyObservable:KVOObservable
ObservableType
KVOObservableProtocol
object
keyPath
options

propertyObservable .flatMapLatest

Subscribe creates AnonymousObserver and calls back to its own subscribe() method via self.asObservable(). Subscribe

observer:KVOObserver
_RXKVOObserver (OC),
Disposable(protocol, easy to remove observer)
KVOObserver
init

_RXKVOObserver
target
keyPath
callback

observeValueForKeyPath
callback
dispose

From there, the whole observeWeakly low-level mechanism was finished, and we could see that the low-level was still working through OC’s KVO

Related memory management issues:

  1. self.person.rx.observerWEAKL. -> KVOObservable - > personWill there be circular references? Please look at:

unowned
KVOObservable
person