{ let disposeBag = DisposeBag() } struct Person { var name: Variable<String> } let scott = Person(name: Variable("Scott")) let lori = Person(name: Variable("Lori")) let person = Variable(scott) person.asObservable() .flatMap { $0.name.asObservable() } .subscribeNext { print($0) } .addDisposableTo(disposeBag) person.value = lori scott.name.value = "Eric"
let disposeBag = DisposeBag() struct Person { var name: Variable<String> } let scott = Person(name: Variable("Scott")) let lori = Person(name: Variable("Lori")) let person = Variable(scott) person.asObservable() .flatMapLatest { $0.name.asObservable() } .subscribeNext { print($0) } .addDisposableTo(disposeBag) person.value = lori scott.name.value = "Eric" }
var name: Variable<String> } let scott = Person(name: Variable("Scott")) let lori = Person(name: Variable("Lori")) let person = Variable(scott) person.asObservable() .debug("person") .flatMapLatest { $0.name.asObservable() } .subscribeNext { print($0) } .addDisposableTo(disposeBag) person.value = lori scott.name.value = "Eric" } --- Example of: flatMapLatest --- 2016-05-28 07:31:22.555: person -> subscribed 2016-05-28 07:31:22.556: person -> Event Next((Person #1)(nam...able<Swift.String>)) Scott 2016-05-28 07:31:22.557: person -> Event Next((Person #1)(nam...able<Swift.String>)) Lori 2016-05-28 07:31:22.560: person -> Event Completed 2016-05-28 07:31:22.560: person -> disposed