Tushar Gupta
Dec 24, 2018 · 4 min read

Yes, Functional & Reactive Programming isn’t for the faint heart. There, I said it. This is the first question that pops into mind as soon as we see the words “Reactive Programming”. But then what is the point of learning it. This is what we are going to explore in our new episode with Ashish Krishnan & Gurpreet Singh from Kite & Amanjeet Singh from 1mg.

Image Credits: https://quickbirdstudios.com/blog/what-is-functional-reactive-programming-frp/

Show Notes:

Why is Functional & Reactive difficult?

These are difficult because of the way we have been taught programming from our childhood. Object-Oriented & Imperative Paradigms have been dominating from a few decades but times are changing. CPUs have becomes multi-core instead of getting faster and Memory has become cheap. Systems are not synchronous anymore but fast, responsive and async. We need an easy way to deal with all the asynchrony in the world and this is where ReactiveX (Reactive Extensions) have helped us.

RxJava/RxKotlin — The reactive libraries.

ReactiveX have made it very easy to write reactive code in most of our imperative languages by providing a set of tools which work on streams of data whether synchronous or asynchronous. RxJava is the API for Asynchronous programming with observable streams for Java language. RxKotlin enhances usage of RxJava API in a beautiful Kotlinish way but works with RxJava.

What is the fundamental of ReactiveX?

ReactiveX is the combination of the best ideas from
the Observer pattern, the Iterator pattern, and functional programming. How so?. We discuss that in the podcast.

Lego Blocks Of RxJava:

Observables: Data streams that we hook into. These emits data/events which we listen to and operate upon. Remember subscribing to articles or newsletters online. Yeah those are our observables.

Operators: This is where Rx borrows stuff from Functional world. Operators are functions, mostly pure, which allow operating on data emitted by Observables. flatMap , map are just some basic examples. There a lot more which make Rx really fun. Ever used a reader view in your browser to get rid of all the noise in an article and just focus on content. That’s an operator.

Observer: These consume the data and are on the consumer end of the Data streams. Consuming your subscribed article makes you an observer. Someday your subscription will end or you will terminate it, till then the stream lives and keep pushing data down the pipeline.

Schedulers: Rx has given us a very easy to add thread management to Observables. With just two lines of code we can subscribe to a data stream and perform heavy operations on it on another thread, and observe the data back on our main thread.

How does Rx help in Android?

Android is completely asynchronous. Touch events, Activity Life-cycle, Network Operations, Sensor updates everything is async and provides a callback. So how do we compose so many different types of callbacks into a single, composable & simple understandable form. We could make everything Observable because everything is essentially an Observable in Android. It saves us from a ton of Callback Hell.

And above all, we have a single main thread available to us for all operations. Easy asynchronous programming with Rx helps us switch between background thread to main thread and keep our UI jank free.

RxAndroid provides Android specific bindings for RxJava that make writing reactive components in Android applications easy and hassle-free.

What else does Rx have to offer?

There is a lot more to Rx like BackPressure handling, concept of Subjects, Observables vs Flowables vs Singles vs Maybe etc. We do discuss these a bit in our podcast episode but these concepts are a bit advanced and should be learnt slowly.

How do I start?

Our guests and your hosts have prepared a very nice list of articles and websites to start learning Rx today.

Beginner friendly:
1. What is Reactive Programming?
2. Reactive Programming for Android
3. Wrapping your brain around F&RP
4. Introduction to Reactive World
5. Be Reactive Series. Part-I, Part-II, Part-III
6. Interactive Marbles diagrams to understand Reactive Operators
7. Mind blowing Rx Operators via Animations.
8. An effort by Amanjeet Singh to show Rx Operators via Animations on an Android App called RxAnime. Feel free to send pull requests.

A bit Advanced:
1. Reactive Manifesto
2. Reactive Specifications on JVM
3. Advanced RxJava Android Samples by Kaushik Gopal

Some great talks:
1. What if user was a function — A great talk by André Staltz
2. Managing State — By God himself: Jake Wharton

Book you can refer:
1. Reactive Programming in Java


This was an amazing episode and we learned a lot from our guests.
You can follow the Subject Matter Experts on these platforms:

Gurpreet Singh: Twitter, Linkedin
Ashish Krishnan: Twitter, Linkedin
Amanjeet Singh: Twitter, Linkedin, Github

Happy faces from Left: Gurpreet, Ashish & Amanjeet

We are inviting Android Developers to contribute back to the community via AndroIDIOTS. If you are interested in recording a podcast or writing tech articles, we would love to have you on board. Here is a small form you can fill so we can get back to you:

Follow us on twitter for regular updates and feel free to DM the hosts (Anupam & Tushar) for any queries.

Cheers!!

AndroIDIOTS

An android developer publication to stay updated with whats new in android, best practices and how to become a better android developer

Thanks to Anupam Singh

Tushar Gupta

Written by

Self-Taught iOS & Android Dev | co-creator AndroIDIOTS | Functional Programming enthusiast | Enjoy diving deep into Architecture & Programming Languages.

AndroIDIOTS

An android developer publication to stay updated with whats new in android, best practices and how to become a better android developer

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade