- Hands-On Reactive Programming with Reactor
- Rahul Sharma
- 285字
- 2021-08-13 15:22:50
Reactive programming
Most of us write imperative applications, where statements are required in order to change the application state. The code is executed and a final state is arrived at. After the state's computation, the state does not change when the underlying factors do. Let's consider the following code as an example:
int value1 = 5; int value2 = 10; int sum = val1 + val2; System.out.println(sum); // 15 value1 = 15; System.out.println(sum); // 15
The sum is still 15, even though value1 has been changed.
On the other hand, reactive programming is about the propagation of change. It is also referred to as declarative programming, where we express our intent and application state as dynamically determined by changes to underlying factors. The preceding sum program example, under a reactive paradigm, would behave as follows:
int value1 = 5; int value2 = 10; int sum = val1 + val2; System.out.println(sum); // 15 value1 = 15; System.out.println(sum); // 25
Consequently, if a program reacts to changes in the underlying factors, it can be called reactive. Reactive programs can be built using imperative techniques, like callbacks. This may be fine for a program that has a single event. However, for applications where hundreds of events are happening, this could easily lead to callback hell; we could have numerous callbacks relying on one another, and it would be really difficult to figure out which ones were being executed. As a result, we require a new set of abstractions that enable us to seamlessly build asynchronous, event-driven interactions across a network boundary. There are libraries in different imperative languages, like Java, that provide us with these abstractions. These libraries are referred to as Reactive Extensions.
- 集成架構(gòu)中型系統(tǒng)
- 工業(yè)機(jī)器人產(chǎn)品應(yīng)用實(shí)戰(zhàn)
- Python Artificial Intelligence Projects for Beginners
- 人工智能工程化:應(yīng)用落地與中臺(tái)構(gòu)建
- 內(nèi)??刂萍捌鋺?yīng)用
- Salesforce Advanced Administrator Certification Guide
- 從零開(kāi)始學(xué)Java Web開(kāi)發(fā)
- Photoshop CS5圖像處理入門(mén)、進(jìn)階與提高
- 大數(shù)據(jù)案例精析
- Mastering Text Mining with R
- 工業(yè)機(jī)器人力覺(jué)視覺(jué)控制高級(jí)應(yīng)用
- PowerMill 2020五軸數(shù)控加工編程應(yīng)用實(shí)例
- Mastering Android Game Development with Unity
- 創(chuàng)客機(jī)器人實(shí)戰(zhàn):基于Arduino和樹(shù)莓派
- Mastering Microsoft Dynamics 365 Customer Engagement