1. What is Reactive Programming?

Wikipedia says:

In computing, reactive programming is an asynchronous programming paradigm 
concerned with data streams and the propagation of change. 
This means that it becomes possible to express static (e.g. arrays) or 
dynamic (e.g. event emitters) data streams with ease via the employed 
programming language(s), and that an inferred dependency within the 
associated execution model exists, which facilitates the automatic propagation of 
the change involved with data flow.

Copy the code

After the translation:

In computing, responsive programming is an asynchronous programming paradigm that focuses on data flow and change passing. This means that static (such as arrays) or dynamic (such as event emitters) data flows can be easily represented using a programming language, and that there are inferred dependencies within the associated execution model that facilitate automatic propagation of changes related to the data flows.Copy the code

2. So what is a programming paradigm?

Programming is to solve problems, and solving problems can have many perspectives and ideas, among which universal patterns are reduced to paradigms. Object-oriented, procedural are programming paradigms.

Responsive programming is a pattern of problem solving that starts with data flow and change. Reactive programming is essentially a response to a flow of data or some kind of change, but when that change happens is unknown, so it is handled in an asynchronous, call-back manner.

It is easier to understand in combination with actual life.

For example, people order food on the APP and then go to do something else, like work or listening to music or watching movies, instead of waiting for food all the time. Call asynchronously without blocking.

Wait until the food arrives downstairs or at the door, the delivery boy will call you a signal, tell you the food arrived, you come down to pick up the food. Sometimes the delivery guy just drops it off at the front desk or in the box and leaves. — Signal callback

The whole process is done in an asynchronous callback fashion. In this way, the user and the delivery boy do not have to wait all the time, which is relatively high efficiency.

3. Supplementary: Synchronous asynchronous, blocking non-blocking

There’s another one on the web that talks about synchronous asynchrony, blocking non-blocking.

Xiao Li 👦🏻 love tea 🍵, need to boil water for tea 🔥.

There are now two kinds of kettles: ordinary kettles, or kettles for short, boil without making a noise. A ringing kettle, or ringing kettle for short, makes a jarring noise.

    1. Xiao Li 👦🏻 Put the kettle on the fire and wait for the water to boil. (synchronous blocking) Xiao Li 👦🏻 feels a bit silly. (Wait for the water to boil)
  • 2. Xiao Lee 👦🏻 Put the kettle on the fire, watch TV in the living room, and check the water in the kitchen from time to time. (Synchronous non-blocking) Xiao Li 👦🏻 still feels a bit silly. (It’s a hassle to check it again and again.)

  • 3. Xiao Li 👦🏻 Put the kettle on the fire and wait for the water to boil. (asynchronous blocking) Xiao Li 👦🏻 still feels a bit silly. (Wait for the water to boil)

    1. Xiao Li 👦🏻 put the ring kettle on the fire, go to the living room to watch TV, the kettle rang before no longer go to see it, rang again to take a pot. (asynchronous non-blocking) Xiao Li 👦🏻 feels clever. 💡
  • The so-called synchronous asynchronous, only for the kettle. Common kettle, synchronous; Ring the kettle, asynchronously.

  • The so-called blocking non-blocking, only for Xiao Li 👦🏻. Standing xiao Li 👦🏻, block; Lee watching TV 👦🏻, non-blocking. 1 and 3 lee 👦🏻 is blocked, he did not know the earthquake. Although 3 rings the kettle is asynchronous, but for the standing xiao Li 👦🏻 has no meaning. Asynchrony is typically used in conjunction with non-blocking to make asynchrony work.