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

RxSwift reintroduction

RxSwift reintroduction

USAMI Kosuke

June 29, 2018
Tweet

More Decks by USAMI Kosuke

Other Decks in Programming

Transcript

  1. ίʔυྫ : UIButton button.rx.tap .subscribe { [unowned self] _ in

    // Ϙλϯλοϓ࣌ͷॲཧ } .disposed(by: disposeBag)
  2. ίʔυྫ : UITextField textField.rx.text .subscribe { [unowned self] _ in

    // ςΩετೖྗ࣌ͷॲཧ } .disposed(by: disposeBag)
  3. ΠϕϯτॲཧͷྲྀΕ • Observable ʹ Πϕϯτ͕ྲྀΕͯ͘Δ Sequence • rx.tap, rx.text, rx.notification,

    rx.response • Observable Λ subscribe ͢ΔͱΠϕϯτΛड͚औΕΔ • dispose ʹ subscription ͷഁغ
  4. Relay ͷ࢖͍ํ : accept • accept Ͱ Relay ʹ .next

    ΠϕϯτΛૹΔ͜ͱ͕Ͱ͖Δ let relay = BehaviorRelay<String>(value: "000") relay.accept("111") relay.accept("222")
  5. Relay ͷ࢖͍ํ : bind • subscribe ͷ୅ΘΓʹ bind ͕࢖͑Δ relay

    .bind(to: label.rx.text) textField.rx.text .bind(to: relay)
  6. BehaviorRelay / PublishRelay • ྆ऀͷҧ͍ • ॳظ஋Λ࣋ͭ / ࣋ͨͳ͍ •

    value ϓϩύςΟͰݱࡏ஋͕औಘͰ͖Δ / Ͱ͖ͳ͍ • subscribe ͨ͠ͱ͖ݱࡏ஋͕ྲྀΕΔ / ྲྀΕͳ͍