Issue: Race condition, when the user makes changes to input, there are cases where the previous data overrides the latest API call.
To solve this race condition, we can either make streams synchronous so that the last stream gets started if the previous stream is completed or cancel the previous stream and have only one stream active. This can be achieved by using ConcatMap and SwitchMap respectively. We will also be using debounce time and distinctUntilChanged to emit events once the user stops making changes to the data and will not emit events if the data is the same.
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.
Working as a full stack developer for 4 years and always learning.