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

入門ReactiveX / about ReactiveX

入門ReactiveX / about ReactiveX

Mihyaeru

June 27, 2016
Tweet

More Decks by Mihyaeru

Other Decks in Technology

Transcript

  1. ೖ໳ 3FBDUJWF9 /%4 PO @mihyaeru21 ஶ ϛώϟΤϧ༁ A library for

    composing asynchronous and event-based programs by using observable sequences. ͟ ͬ ͘ Γ ൛
  2. ཱͪҐஔ  ճ ෳ਺ճ ಉظ T getData() Iterable<T> getData() ඇಉظ

    Future<T> getData() Observable<T> getData() from http://reactivex.io/intro.html
  3. TVCTDSJCF  stream.catchErrorJustReturn(0) .map { $0 * 10 } .subscribe(

    onNext: { value in print("onNext: \(value)") }, onError: { error in // この例ではエラーは流れてこない print("onError: \(error)") }, onCompleted: { print("onCompleted") } )
  4. ඇಉظͷஞ࣮࣍ߦ  fetchHoge().subscribeNext { res in fetchFuga(id: res.id).subscribeNext { res2

    in fetchPiyo(key: res2.key).subscribeNext { res3 in // do something with res3... } } } TVCTDSJCF/FYU͸ɺ/FYUΠϕϯτ͚ͩTVCTDSJCF͢Δ΍ͭ
  5. qBU.BQ  fetchHoge() .flatMap { fetchFuga(id: $0.id) } .flatMap {

    fetchPiyo(key: $0.key) } .subscribeNext { res in // do something with res... }