官术网_书友最值得收藏!

  • Spring 5.0 Projects
  • Nilang Patel
  • 428字
  • 2021-07-02 12:35:00

Reactive Programming

Reactive Programming can be used to build a Reactive System. By definition, Reactive Programming is a programming practice or pattern that is aligned around the data flow and the propagation of the changes. The changes in data are automatically propagated by the underlying execution model through the data flow. 

To make it simple, Reactive Programming is a way to handle asynchronous data streams in a more effective manner. In other words, it is programming dealing with an asynchronous data stream, or it can be called the subset of asynchronous programming. Reactive Programming is a way of execution where new information will push the flow forward, rather than having the flow controlled by an execution thread.

The data stream is a series of business events that happen during the system execution, such as various keyboard or mouse events, HTML field changes, HTTP requests, notification, REST API data fetch, triggering validations, changing of web component state, data updates, or anything else that can cause a change in the data stream or alter a program behavior. 

In short, Reactive Programming covers a dynamic reaction in the stream that is caused by the asynchronous data flow. When the changes happen in one component, a reactive library or framework will automatically propagate those changes to other components. It is quite possible to define a static order in which the changes are propagated.

The following diagram shows how Reactive Programming is different to imperative programming:

In imperative programming, the threads talk to each other in a synchronous way that results in blocking communication. A thread has to wait until the dependent thread of a resource is free, which can cause inefficient utilization and an easy bottleneck situation in the system. On the other hand, Reactive Programming doesn't need to wait; in fact, it is informed once the resource is available so that it can do other work in the meantime. This reduces the risk of the system hanging and makes it responsive. This effectively maintains smooth resource usage. 

Reactive Programming suggests breaking down the given requirements into separate and individual steps that can be accomplished in an asynchronous, non-blocking style, and later on, combined to form a final output. In the Reactive Programming context, asynchronous means that the processing of a message or event occurs at some arbitrary time, most probably in the future.

The asynchronous and non-blocking nature of Reactive Programming is particularly useful in application environments where resources are shared; there is no need to halt the thread of execution while a resource is elsewhere engaged.

主站蜘蛛池模板: 沐川县| 常宁市| 瑞安市| 舒兰市| 凤翔县| 阿鲁科尔沁旗| 浦江县| 尉氏县| 荥经县| 彰化市| 廊坊市| 阿鲁科尔沁旗| 潜江市| 建水县| 平安县| 城步| 龙游县| 平遥县| 夹江县| 六枝特区| 花莲县| 克拉玛依市| 会昌县| 德清县| 宁波市| 达拉特旗| 宁夏| 桓仁| 京山县| 顺昌县| 木兰县| 乌鲁木齐县| 六盘水市| 河东区| 宁明县| 高淳县| 兴仁县| 双辽市| 桂东县| 昆山市| 新丰县|