Skip to content

Codelab project for demonstration of RxJava features

Notifications You must be signed in to change notification settings

jraska/RxJava-Codelab

Repository files navigation

RxJava Codelabs: Basic + Advanced

Build Status

Introduction

Reactive programming is mentioned everywhere these days. It solves many common issues of imperative programming in an elegant way. Dozens of libraries are springing up, giving developers access to powerful tools that make their everyday development life easier. However, it can take time to learn how to wield these tools effectively as they are often difficult to understand and if used improperly they can sometimes do more harm than good.

These codelabs will first go through RxJava basics, in order to demonstrate the main concepts and common use-cases of the ReactiveX framework, as well as reactive programming in general. It should make RxJava and reactive programming much clearer to you and give you lots of ideas of when and where you might want to use it. Once you have seen what it can do, you won't want to go back to how you were programming before!

The advanced codelab will take you more into deep of reactive world, we will go into detail and we will discover more of its beauty, because its endless.

Prerequisites

  1. Java 8 SDK
  2. IntelliJ (any edition) or any other IDE you like

Project setup

  1. Clone this repo (GitHub Desktop, SourceTree or git clone https://github.com/jraska/RxJava-Codelab.git)
  2. Open it in IntelliJ or other IDE
  3. Try to run SetupTest from your IDE
  4. Call for help if it doesn't work

RxJava Basics Codelab covers (slides)

  • What is a stream? Observable contract
  • How to create Observables
  • Transformations
  • Composing
  • Error handling
  • Threading - Schedulers

RxJava Advanced Codelab covers (slides)

  • Observable feat. Single, Maybe, Completable
  • Hot/Cold Observables
  • Testing
  • Use cases - cache/refresh, polling, caching, ...
  • Backpressure - Observable vs. Flowable
  • Other reactive libraries interoperability

How to use the Code Lab

  • There are tasks for different areas formed as unit tests and having a format Task{Order}{AreaOfFocus} (e.g. Task2Transformations).
  • Each of these tasks has a method with a TODO explaining what to do and giving hint which operator might be useful. Very often there are multiple solutions to given problem.
  • Each Task has a solution with format SolutionTask{Order}{AreaOfFocus} (e.g. SolutionTask2Transformations).
  • Recommended order is doing the tasks by order of their numbers, however jumping based on area of interest is encouraged as well.

Links