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

Migrating to RxJava2

Migrating to RxJava2

RxJava is nearing the end of its development in favor of RxJava2. This presents at a high level some things that are changing in RxJava2.

Etienne Lawlor

March 29, 2018
Tweet

More Decks by Etienne Lawlor

Other Decks in Technology

Transcript

  1. Android Developers Los Angeles • March 31, 2018 - end

    of line, no further development • June 1, 2017 - feature freeze (no new operators) only bug fixes RxJava 1.x
  2. Android Developers Los Angeles • Java 8 lambda-friendly API RxJava

    2.x • Follows the Reactive-Streams architecture • No longer accepts null values • Updates to the reactive base types
  3. Android Developers Los Angeles • Flowable - 0..N flows, supporting

    Reactive-Streams and 
 backpressure • Observable - 0..N flow, no backpressure • Single - a flow of exactly 1 item or an error (used for API calls) • Maybe - a flow with no items, exactly one item or an error 
 (used for Database calls) • Completable - a flow without items but only a completion or
 error signal Reactive Base Types
  4. // Latest version of RxJava2 implementation "io.reactivex.rxjava2:rxjava:2.1.7" // RxAndroid provides

    Android Scheduler implementation "io.reactivex.rxjava2:rxandroid:2.0.1" // If you use Retrofit2, then you will need the RxJava2 adapter implementation "com.squareup.retrofit2:adapter-rxjava2:2.3.0"
  5. // Setup Retrofit object Retrofit retrofit = new Retrofit.Builder() .addCallAdapterFactory(RxJava2CallAdapterFactory.create())

    .addConverterFactory(GsonConverterFactory.create()) .baseUrl(baseUrl) .client(okHttpClient) .build();
  6. Android Developers Los Angeles MovieHub - Showcases popular movies, tv

    shows, and people from The Movie Database. https://github.com/lawloretienne/MovieHub
  7. Android Developers Los Angeles • http://engineering.rallyhealth.com/mobile/rxjava/reactive/2017/03/15/migrating-to- rxjava-2.html References • https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0

    • https://blog.mindorks.com/migrating-from-rxjava1-to-rxjava2-5dac0a94b4aa • https://blog.kaush.co/2017/06/21/rxjava1-rxjava2-migration-understanding-changes/ • http://www.nurkiewicz.com/2017/08/1x-to-2x-migration-observable-vs.html • https://caster.io/lessons/rxjava-2-migrating-your-first-stream-from-rxjava-1/ • https://futurice.com/blog/the-next-step-for-reactive-android-programming