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

  • Spring 5.0 Projects
  • Nilang Patel
  • 338字
  • 2021-07-02 12:35:01

Reactive Programming techniques

Reactive Programming is event-based in most cases. In Reactive Programming, the APIs are exposed in the following two flavors:

  • Callback: In this type, the anonymous routines are registered to event sources as callback functions. They will be invoked when the event is triggered by the data flow.
  • Declarative: The events are observed through well-defined functional compositions, like a filter, map, and other stream-based operations, like count, trigger, and so on.

Reactive Programming puts the importance on data flow rather than the flow of control, so it is not uncommon to consider it as a data flow programming. There are various techniques that are used to achieve Reactive Programming as follows:

  • Futures and promise: It is referred to as a technique to define the variable and assign its value. Though futures and promise are used interchangeably, they are not exactly the same. The future is used to describe a read-only view of a variable (or, say, define the variable), while the promise is a writable, single assignment container that is used to set the value of a variable in future. 
  • Reactive Streams: It is defined as a standard for the processing of asynchronous streams that enables non-blocking, backpressure transmutations between sources from where the events are initiated and the destination where they are observed.
  • Data flow variables: It is a variable whose value depends on a given input, operations, and other cells, and is updated automatically when changes happen to source entities. You can think of a data flow variable as a spreadsheet cell, where a change in the value of one cell causes a ripple effect to others based on the assigned formula.

In addition to this, there are various frontend libraries available, like React.js, AngularJS, Ractive.js, Node.js, and so on, which are used to develop reactive frontend applications. Other programming languages and frameworks providing native support for reactive applications are Scala, Clojure, and GoLang, along with Java 9 and Spring 5. We will see reactive features of Spring 5 later in this chapter.

主站蜘蛛池模板: 任丘市| 阜阳市| 乳源| 菏泽市| 枝江市| 河源市| 新源县| 康平县| 长治市| 额尔古纳市| 临高县| 禹州市| 老河口市| 涪陵区| 珠海市| 云霄县| 平凉市| 城口县| 台安县| 宣汉县| 崇明县| 宜章县| 临沂市| 西青区| 神池县| 潼南县| 白水县| 林西县| 开阳县| 仁怀市| 迁安市| 恩平市| 房山区| 肃南| 宁乡县| 铜梁县| 定安县| 湘潭县| 兴宁市| 普定县| 乐至县|