Skip to content

Instantly share code, notes, and snippets.

@shoheiyokoyama
Created August 3, 2017 00:59
Show Gist options
  • Save shoheiyokoyama/f867f08a03278eb40ad9a0793cfb663c to your computer and use it in GitHub Desktop.
Save shoheiyokoyama/f867f08a03278eb40ad9a0793cfb663c to your computer and use it in GitHub Desktop.
// 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