Reactive Programming — What Now?

INTRING
1 min readFeb 14, 2021

--

I have been working in software development for four years and was aware of Reactive programming but never implemented it. I got a chance to work on a new module and started implementing reactive programming. Here are some key insights.

I always read that reactive programming deals very well with “asynchronous” tasks and think of everything as streams. I always read that but never understood it. I just want to explain what I learned recently.

There are a lot of asynchronous activities going on in the application like API calls, user events… etc.

Let’s take an example.

  1. I have a list of records in a table that are fetched by an API call.
  2. Users can filter the records which makes an API call and brings back filtered records.

Before Reactive Programming, I would write something like this

filter records before data loads

The issue with this is the load data takes more time to load and when the user filters the data, it doesn’t make any delay and returns the data but the loading API returns the data after filter API and overrides the user event data.

Once I understood the problem, I started updating the code using reactive Extensions and started making it reactive.

Here is how the code looks like…

filter records before data loads

The data when user filter without loading data it cancels the previous request and loads the new data, this way it deals with asynchronous programming

From both examples, we can take a look at how using reactive programming is beneficial and how it reacts to events compared to passive programming.

--

--

INTRING

INTRING: India transforming chaos to order. Passionate about simplifying lives, driving positive change. Innovative solutions for an organized India.