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

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());
主站蜘蛛池模板: 巴林左旗| 涟源市| 丁青县| 内黄县| 荣成市| 桐柏县| 中江县| 武城县| 化德县| 馆陶县| 武清区| 冕宁县| 潜山县| 松阳县| 界首市| 兴海县| 郧西县| 运城市| 都江堰市| 黄浦区| 华坪县| 本溪市| 酉阳| 太康县| 西盟| 开鲁县| 分宜县| 虎林市| 沈丘县| 丹巴县| 西城区| 洪洞县| 金门县| 乐陵市| 贺州市| 同心县| 广德县| 黔南| 秦安县| 房产| 大关县|