Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RxSwiftと愉快な仲間たち / RxSwift with Units

RxSwiftと愉快な仲間たち / RxSwift with Units

Gotanda.mobile #1 on 2016/05/20

Mihyaeru

May 20, 2016
Tweet

More Decks by Mihyaeru

Other Decks in Technology

Transcript

  1. Driver let userName = fetchUser() .map { $0.name } .observeOn(MainScheduler.instance)

    userName.bindTo(label.rx_text) userName.bindTo(otherLabel.rx_text)
  2. Driver let userName = fetchUser() .map { $0.name } .observeOn(MainScheduler.instance)

    .share() userName.bindTo(label.rx_text) userName.bindTo(otherLabel.rx_text) share()͠ͳ͍ͱ2ճൃՐ͢Δ
  3. Driver let userName = fetchUser() .map { $0.name } .asDriver(onErrorJustReturn:

    "") userName.drive(label.rx_text) userName.drive(otherLabel.rx_text)
  4. Driver let userName = fetchUser() .map { $0.name } .asDriver(onErrorJustReturn:

    "") userName.drive(label.rx_text) userName.drive(otherLabel.rx_text) share()తͳ͜ͱΛ͍ͯ͠Δ͔ΒൃՐ͸1ճͷΈ
  5. Variable let variable = Variable(0) variable .asDriver() .map { "value:

    \($0)" } .drive(label.rx_text) variable.value = 99 print("variable.value = \(variable.value)")
  6. Variable let variable = Variable(0) variable .asDriver() .map { "value:

    \($0)" } .drive(label.rx_text) variable.value = 99 print("variable.value = \(variable.value)") label.text͕”value: 99”ʹͳΔ Variable͸ΤϥʔΛྲྀ͞ͳ͍͔Β Ҿ਺ແ͠൛ͷasDriver()͕͋Δ ಉظతʹ஋ΛऔಘͰ͖Δ
  7. ౜ಥͳ·ͱΊ • ศརػೳͨͪ • Driver • Variable • ControlEvent/ControlProperty •

    ͳͯ͘΋ࢮͳͳ͍͚Ͳ͋Δͱ஍ຯʹศར • ஍ຯʹ࢖ͬͯ͜