Created
August 3, 2017 00:59
-
-
Save shoheiyokoyama/f867f08a03278eb40ad9a0793cfb663c 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
// Reference: [Transforming_Operators.xcplaygroundpage](https://github.com/ReactiveX/RxSwift/blob/master/Rx.playground/Pages/Transforming_Operators.xcplaygroundpage/Contents.swift) | |
let disposeBag = DisposeBag() | |
struct Player { | |
var score: Variable<Int> | |
} | |
let 👦🏻 = Player(score: Variable(80)) | |
let player = Variable(👦🏻) | |
player.asObservable() | |
.flatMap { $0.score.asObservable() } | |
.subscribe(onNext: { print("score: \($0)") }) //score: 80 | |
.disposed(by: disposeBag) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment