Developing great apps nowadays require many things like handle User Interaction, handle network related stuff, manage data as well as present them. For that Developer has to write lots of concurrent as well as asynchronous code.
Nowadays if you take a look on the internet as a developer than somewhere, you have read the term “Reactive programming.“ You might wonder what’s this term actually means and why it takes storm between the developers. Many developers say it is the “Next big thing” in the programming world. Maybe as a developer you are still unaware what the world is talking about so you are curious to know on this and make yourself to be the part of this incredible world of programming.
So if you are bibelot about this topic and search on the internet than here is what type of definition you will find:
“Reactive programming is an asynchronous programming paradigm concerned with data streams and the propagation of change.”
At the initial stage, it is tough to understand what it really meant. This is the reason why I am writing this blog. So that everyone is able to know how reactive programming will help you in coding with an easy and understandable way.
I will try to explain to you in a straightforward and fun manner that how it will attract you to use in your real-world apps and projects. I am sure you will definitely understand this by the fun conversation between me and my friend Taral.
As an application developer, we always need to make our app smooth as butter. For that we have to handle many things like below :
Handle multiple URL responses at the same time
Multiple UI changes
Handling all the other frameworks, we are using
Many more things
To tackle all these, we often use many frameworks also use some logic by putting UI related changes to the Main thread and other time-consuming stuff in a background thread. We’ll try to keep our main thread free. Writing code that truly runs in parallel, however, is somewhat complicated, especially when different bits of code need to work with the same pieces of data. It’s hard to argue about which part of code updates the data first, or which code read the latest value.
So for an alternative of all these, here comes the Reactive Programming to give you power and fight for your code.
Reactive Programming ~= Asynchronous programming
Basically, Rx is asynchronous programming that handles your code to react the data in observable sequences. It defines the basic programming in which one component emits the data, and other parts which are registered to receive will propagate those changes.
There are three building blocks of Rx
Observables — Component that Emits the Data
Observers — Components that subscribes to observable to get changes
Schedulers — schedule the different pieces of data coming from observable
For example :
X = Y + Z
X is an observer here because it subscribes to the result of y+z
Y & Z are observables here because it omits the changes.