+8618851824128 vitaly.ignatovich info@agriocom.com

Reactive programming is counter intuitive at first, like many other advanced patterns.

In fact, it is most natural way of programming of event based applications. Every UI application consists of small procedural routines glued together with some event driven framework. Events are fired upon user’s interaction with our application. Patterns of interactions are totally random.

There have been many paradigms to implement event driven software. Most known being MVC and it’s flavors like MVVC, MVAC, etc. They are trying to put together linear parts of code to make it event driven or data driven. Model View Controller is based on idea that we can define an abstract model of underlying data. Then create a view that would display this data to the user and take her input for modification. Controller connects view and model to marshal data between view and model in both directions. There are numerous implementations of MVC frameworks. In fact, every web application is MVC with different degree of modularity.

The main problem is that it’s impossible to define clear boundary between the model, view and controller. It’s always a kind of mixture.

So what is reactive programming? Reactive programming has basically same concept like MVC but it completely automatizes controller. Any changes in underlying data model are automatically reflected in view and vice versa. Both ways changes are guaranteed to be synchronized without any programming efforts.

Imagine you have a boolean variable somewhere in your data model and a checkbox anywhere in your UI. If checkbox is changed, variable is automatically updated. Opposite is also true. If checkbox changed it’s value, boolean variable is automatically updated. So you don’t need controller between the UI and the model.

This makes the UI software exceptionally simple and robust.

Examples of reactive programming are web frameworks like Angular, React and Vue Js. They are getting more and more popularity, taking over old school libraries like ExtJS.