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

The Mono reactive type

 

A Reactive Streams Publisher with basic Rx operators that completes successfully by emitting an element, or with an error.
– Mono JavaDoc

Mono<T> is a Publisher<T> that supports 0..1 elements.

The definition of Mono is as follows:

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

As detailed in the documentation, the following figure shows the workings of Mono:

Figure 08: Working of Mono

Mono<Void> should be used for a Publisher that completes with no value. The documentation explains each method and how it works using a marble diagram, which is self-explanatory. Again, this type is also supported by Spring 5 and Spring Security.

JavaDoc for Mono contains more information: https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html.

Let's have a look at some examples:

  • Creating empty Mono:
Mono<String> emptyMono = Mono.empty();
  • Creating Mono with a value in it:
Mono<String> itemMono = Mono.just("Spring Security Reactive”);
  • Creating Mono that emits an exception:
Mono.error(new CreatedException());
主站蜘蛛池模板: 仁化县| 新泰市| 高州市| 焉耆| 宜春市| 遂平县| 三门峡市| 新巴尔虎左旗| 桑植县| 靖安县| 班戈县| 清新县| 湖州市| 汉沽区| 宁乡县| 河南省| 天门市| 西畴县| 夹江县| 尚义县| 连山| 金坛市| 株洲市| 柞水县| 亚东县| 新沂市| 平顶山市| 那坡县| 新郑市| 泰宁县| 横山县| 罗甸县| 吴旗县| 普安县| 瓮安县| 天等县| 韶关市| 开化县| 张北县| 武山县| 永仁县|