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

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());
主站蜘蛛池模板: 葵青区| 郧西县| 财经| 彰化县| 桑日县| 灌阳县| 农安县| 班戈县| 灵璧县| 黄大仙区| 伊金霍洛旗| 南充市| 河曲县| 建瓯市| 墨玉县| 阿城市| 望谟县| 调兵山市| 安义县| 峡江县| 杭锦后旗| 弋阳县| 无棣县| 澄迈县| 田东县| 灌阳县| 牟定县| 潮州市| 嘉善县| 金湖县| 集安市| 湄潭县| 城口县| 鱼台县| 岱山县| 花莲县| 平顶山市| 栖霞市| 万源市| 张家口市| 都匀市|