I have implemented compactMap
over BehaviorRelay
and it works just fine:
class MyClass{
let subject = BehaviorRelay(value: 1)
func doSomething() {
subject.compactMap{ $0 }.subscribe(onNext:{
print($0)
}).disposed(by: disposeBag)
}
My question is if for some reason I want to cancel/stop the BehaviorRelay
. There is a way to cancel/stop compactMap
?