This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let disposeBag = DisposeBag() | |
let persons = PublishSubject<Person>() | |
persons | |
.flatMapLatest { | |
$0.car | |
} | |
.subscribe(onNext: { | |
print($0) | |
}) | |
.disposed(by: disposeBag) | |
let john = Person(car: BehaviorSubject(value: "Toyota Corolla")) | |
persons.onNext(john) | |
let alice = Person(car: BehaviorSubject(value: "Honda Accord")) | |
persons.onNext(alice) | |
john.car.onNext("Ford Model T") | |
// Output: | |
// Toyota Corolla | |
// Honda Accord |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment