Press "Enter" to skip to content

RxJava for Android (100+ Examples Pack) – Now in Kotlin!!!!!

6

In the last few months we published a ten-part series about RxJava that covered over than 70 operators, including some variants of them, in different scenarios. Now,  we decided to wrap all examples together in a single app plus some other examples we found useful. The idea is basically to provide a single app with over than 100 examples of RxJava which you can use as a reference when dealing with RxJava. 

Update: This project was entirely convert to Kotlin! Yes, no more Java code in there… Just Kotlin! In case you still want the Java code, clone the JAVA_CODE tag in the GitHub repository.

I made it during my Kotlin learning process, and it was a great opportunity for me to improve my Kotlin skills. Hope you can take advantage of it as well.

Note that since RxJava 1.x version is no longer supported, I decided to start migrating this project to use RxJava 2.x instead. I hope to get it done soon… so, stay tuned on the next updates.

In order to make it easy to find the examples throughout the app, we divided them in different categories. They are:

  • Operators Examples: Basically it contains examples of many operators used to filtering, combining, transforming data, dealing with error handling, etc.
  • Backpressure Examples: Contain different approaches to deal with backpressure.
  • Hot Observable Examples: Show how to use Hot Observables by using operators such as cache, replay, etc.
  • Parallelization: Demonstrate how to do real parallelization using RxJava operators and schedulers.
  • General Examples: Contain some examples that do not fit in any of the previous categories.

Different from the previous articles, we are not going into the details about any example provided on the demo app. The reason is that either they were already covered into details in one of the articles of our RxJava series (you can find the links below) or they were based on external articles, so you can go directly to those articles and see the the authors’ explanations.

It’s worth mentioning whenever an example was based on an external article, we added a reference to the sources, so all the credits go to the authors.

That being said, you can find below a list of all covered examples on the demo app and the articles on which they were based:

  • General Examples
    • Simulate Server Polling (4 examples) – This example is useful when we need to poll a server periodically until it finishes a certain task.
    • Server Polling After Local Data Processing (3 examples) – This example is useful when we need to poll a server and process some data locally, and only after finish local processing, poll the server again.
    • Typing Indicator (1 example)
    • Drawing Example (1 example) – This example shows how to react to mouse events as well as  listen for SeekBar and menu item click events by using RxBindings library.
    • Broadcast System Status (1 example) – This example shows how to listen for broadcast system messages by using RxBroadcast library.

You can download demo app here (now in Kotlin!).

Final Words

As mentioned before, the main idea for this article is to wrap in a single app a bunch of RxJava examples. Some of them were previously published on our RxJava ten-part series, and some others were based on some articles I found on the Internet.

I really hope it can be useful, and as usual, if you have any question, please, leave a comment below.

Thanks for your audience! See you on the next article.

  • Arnav Puri

    Hi, is there any apk file available, or I will have to build on my own from project?
    Great work btw 😊

    • androidahead

      Hi @arnavpuri:disqus , there is no apk, just the code (on GitHub), so you need do compile it and generate the apk by yourself. Thanks!

  • Gohar Ali

    This demo app uses RxJava 1. Is there any other demo app that is using RxJava 2. Or any link where I can get some insight for RxJava 2.

    • androidahead

      Hi @disqus_R4qkqfDF5t:disqus . Actually I’m planning to migrate it to version 2, but can’t say when I’ll be able to do so. Maybe if you Google it, you can find many great articles about RxJava2. Thanks for your comment.

      • Gohar Ali

        @androidahead:disqus Your posts were well explained that’s why asked you if you have any Rxjava 2 examples. Well thank you for the reply.

        • androidahead

          @disqus_R4qkqfDF5t:disqus , Thanks again for your kind words. I actually try to put as much effort as possible when writing posts in order to bring up useful information. This is the way I found to give something back to this lovely Android community that always supported me when I needed (and still need). Hope you keep enjoying next posts.