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

The Flux reative type

A Reactive Streams publisher with Rx operators that emits 0 to N elements, and then completes (successfully or with an error). For more information, you can check the following link: https://projectreactor.io

Flux<T> is a Publisher<T> with basic flow operations and supports 0..n elements.

The definition of Flux is as follows:

public abstract class Flux<T>
extends Object
implements Publisher<T>

The following figure, as depicted in the Flux documentation, explains the working of Flux in more detail:

Figure 7: Working of Flux

Flux support is in Spring 5 and a variety of other important modules, including Spring Security. Operators acting on Flux would create new publishers.

Please refer to the Reactor Flux documentation for more information: https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html.

Now, let's have a look at some code examples where usage of Flux is shown:

  • Creating empty Flux:
Flux<String> emptyFlux = Flux.empty();
  • Creating Flux with items in it:
Flux<String> itemFlux = Flux.just("Spring”, "Security”, "Reactive”);
  • Creating Flux from an existing list:
List<String> existingList = Arrays.asList("Spring”, "Security”, "Reactive”);
Flux<String> listFlux = Flux.fromIterable(existingList);
  • Creating Flux that emits every x milliseconds in an infinite manner:
Flux<Long> timer = Flux.interval(Duration.ofMillis(x));
  • Creating Flux that emits an exception:
Flux.error(new CreatedException());
主站蜘蛛池模板: 香港 | 定安县| 炉霍县| 富锦市| 铜鼓县| 潜江市| 含山县| 卢龙县| 乌兰察布市| 徐汇区| 彰化县| 田林县| 山丹县| 恩平市| 梅州市| 东阿县| 留坝县| 莱芜市| 区。| 蓝山县| 虎林市| 安岳县| 新乐市| 隆回县| 甘泉县| 马鞍山市| 永宁县| 墨脱县| 玉环县| 喀喇沁旗| 安溪县| 霍山县| 邳州市| 湘潭市| 乌鲁木齐市| 泰宁县| 道真| 丰台区| 漳州市| 清河县| 伊宁县|