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

Taking Glance at RxJava 2.0

Taking Glance at RxJava 2.0

* UPDATED (08/25/16)
RxJava 2.0-RC 1 is released today and some of the documentation changes were made; the information on this keynote may no longer be up-to-date so please check the official wiki documentation (the links are available below) for more accurate information. Thank you.

RxJava 2.0 is coming this year!

Although the current version of RxJava 1.x is already powerful enough in both Android and Java application development, RxJava keeps evolving and now the first release candidate is coming very soon.

I have talked about upcoming RxJava 2.0, the very tip of it through browsing mostly RxJava repository and its well-documented wiki, as well as the talk of Jake Wharton from Fragmented Podcast.

THIS KEYNOTE DOES NOT COVER ALL THE CHANGES OF RxJava 2.0. (ONLY what I have found out through my research.)

While it is not even released for developers yet, I really hope this new RxJava makes our lives even easier by making it possible to handle asynchronous streams of data even easier than the current RxJava 1.x, with intuitively understandable interfaces and methods.

* reactive-streams.org
http://www.reactive-streams.org/

* Reactive Streams · ReactiveX/RxJava Wiki
https://github.com/ReactiveX/RxJava/wiki/Reactive-Streams

* What's different in 2.0 (draft) · ReactiveX/RxJava Wiki
https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0-(draft)

* amitshekhariitbhu/RxJava2-Android-Samples: RxJava 2 Android Examples - Migration From RxJava 1 to RxJava 2 - How to use RxJava 2 in Android
https://github.com/amitshekhariitbhu/RxJava2-Android-Samples

* JakeWharton/retrofit2-rxjava2-adapter: An RxJava 2 CallAdapter.Factory implementation for Retrofit 2.
https://github.com/JakeWharton/retrofit2-rxjava2-adapter

* 053: Jake Wharton on RxJava (2) – Fragmented
http://fragmentedpodcast.com/episodes/053-jake-wharton-on-rxjava-2/

* Droidcon NYC 2016
http://droidcon.nyc/

Shohei Kawano

August 23, 2016
Tweet

More Decks by Shohei Kawano

Other Decks in Programming

Transcript

  1. Taking Glance at RxJava 2.0 • Differences between 1.x and

    2.x? • Schedule for RxJava 2.0 Release • Up-To-Date with RxJava 2.0 • Conclusion (Android-Focused, no sample code or live coding)
  2. RxJava 2.0 • Following Reactive Streams Specification
 Goal : asynchronous

    streams of data with non-blocking back pressure
 Scope : achieving the above goal with minimal set of interfaces and methods • Following Java 8 Naming Convention • Some breaking changes, some backward compatibles http://www.reactive-streams.org https://github.com/ReactiveX/RxJava/wiki/Reactive-Streams
  3. Differences between 1.x and 2.x? (1) • Package Renaming
 io.reactivex.rxjava:1.x.y

    -> io.reactivex.rxjava:rxjava:2.x.y • io.reactivex.Observable becomes NOT back pressured • io.reactivex.Flowable WILL BE back pressured https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0-(draft)#observable-and-flowable https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0-(draft)#maven-address-and-base-package
  4. Differences between 1.x and 2.x? (2) • Action0 -> java.lang.Runnable

    • Action1 -> Consumer, Action2 -> BiConsumer • ActionN -> Consumer<Object[]> https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0-(draft)#actions
  5. Differences between 1.x and 2.x? (3) • Func3~Func9 → Function3

    ~ Function9 • FuncN → FuncN<Object[], R> • Func1<T, Boolean> → Predicate<T> https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0-(draft)#functions
  6. Differences between 1.x and 2.x? (4) .subscribe() method no longer

    returns Subscription rx.Subscription → io.reactivex.Disposable https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0-(draft)#subscriber
  7. AsyncSubscriber<Integer> subscriber = new AsyncSubscriber<Integer>() { @Override public void onStart()

    { request(Long.MAX_VALUE); } @Override public void onNext(Integer t) { System.out.println(t); } @Overrides public void onError(Throwable t) { t.printStackTrace(); } @Override public void onComplete() { System.out.println("Done"); } }; Flowable.range(1, 10).delay(1, TimeUnit.SECONDS).subscribe(subscriber); subscriber.dispose(); https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0-(draft)#subscriber
  8. AsyncSubscriber<Integer> subscriber = new AsyncSubscriber<Integer>() { @Override public void onStart()

    { request(Long.MAX_VALUE); } @Override public void onNext(Integer t) { System.out.println(t); } @Overrides public void onError(Throwable t) { t.printStackTrace(); } @Override public void onComplete() { System.out.println("Done"); } }; Flowable.range(1, 10).delay(1, TimeUnit.SECONDS).subscribe(subscriber); subscriber.dispose(); https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0-(draft)#subscriber
  9. Schedule for Rx Java 2.0 Release • In the next

    2 weeks: 1st developer preview 
 (Not stable for production yet) • 3 ~ 4 more preview releases and, • Release: Middle of October http://fragmentedpodcast.com/episodes/053-jake-wharton-on-rxjava-2
  10. Up-To-Date with RxJava 2.0 • Check out RxJava GitHub Repository


    - Wiki
 - 2.x Branch • Fragmented Podcast 053: Jake Wharton on RxJava (2) • Droidcon NYC 2016 (Paid Live Stream) http://fragmentedpodcast.com/episodes/053-jake-wharton-on-rxjava-2 http://droidcon.nyc
  11. Available types: • Observable<T>, Observable<Response<T>>, and Observable<Result<T>> where T is

    the body type. • Flowable<T>, Flowable<Response<T>> and Flowable<Result<T>> where T is the body type. • Single<T>, Single<Response<T>>, and Single<Result<T>> where T is the body type. Retrofit2 RxJava2 Adapter https://github.com/JakeWharton/retrofit2-rxjava2-adapter