Created
August 3, 2017 01:04
-
-
Save shoheiyokoyama/109c1697c1fb02c47557077904b9618a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 killua = Player(level: Variable(50)) | |
let gon = Player(level: Variable(50)) | |
let bisque = Player(level: Variable(70)) | |
let player = PublishSubject<Player>() | |
player.asObservable() | |
.flatMapWithIndex { player, index -> Observable<Int> in | |
if index < 2 { | |
return player.level.asObservable() | |
} | |
return .empty() | |
} | |
.subscribe(onNext: { print($0) }) | |
.disposed(by: disposeBag) | |
player.onNext(killua) // 50 | |
killua.level.value = 51 // 51 | |
player.onNext(gon) //50 | |
gon.level.value = 51 // 51 | |
player.onNext(bisque) // level of bisque isn't printed. | |
killua.level.value = 52 // 52 | |
gon.level.value = 52 // 52 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment