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

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.

主站蜘蛛池模板: 盐城市| 松滋市| 连平县| 临邑县| 沙田区| 昆山市| 昌吉市| 商丘市| 白水县| 万全县| 新竹县| 军事| 文安县| 滦南县| 马关县| 天水市| 巴马| 盐津县| 沙坪坝区| 南江县| 金溪县| 肃宁县| 新田县| 扬州市| 马边| 乐业县| 上犹县| 宁河县| 甘泉县| 霍山县| 香河县| 利津县| 临桂县| 台州市| 淮滨县| 车险| 武威市| 梧州市| 丰原市| 迁西县| 杭锦后旗|