- Building RESTful Web Services with Spring 5(Second Edition)
- Raja CSP Raman Ludovic Dewailly
- 177字
- 2021-06-30 19:13:28
Mono
Mono is another type of Reactor can emit only one item at the most. An asynchronous task that just wants to signal completion can use a Mono. Mono mainly deals with a stream of one element, as opposed to Flux's N elements.
Both Flux and Mono make use of this semantic by coercing to the relevant type when using some operations. For example, concatenating two Monos together will produce a Flux; on the other hand, calling single() on Flux<T> will return a Mono <T>.
Both Flux and Mono are Reactive Streams (RS) publisher implementations and conform to Reactive-pull back pressure.
Mono is used in specific scenarios like an HTTP request that produces only one response. In such cases, using Mono would be the right choice.
Returning a Mono<HttpResponse> for an HTTP request like the scenario mentioned earlier is better than returning a Flux<HttpResponse>, as it offers only operators that are relevant to a context of zero items or one item.
Mono can be used to represent no-value asynchronous processes that only have the concept of completion.
Returning a Mono<HttpResponse> for an HTTP request like the scenario mentioned earlier is better than returning a Flux<HttpResponse>, as it offers only operators that are relevant to a context of zero items or one item.
Mono can be used to represent no-value asynchronous processes that only have the concept of completion.
推薦閱讀
- 6G潛在關鍵技術(下冊)
- 面向物聯網的CC2530與傳感器應用開發
- 物聯網網絡安全及應用
- Twilio Cookbook
- 光網絡評估及案例分析
- 萬物互聯:蜂窩物聯網組網技術詳解
- Spring Cloud微服務架構進階
- SSL VPN : Understanding, evaluating and planning secure, web/based remote access
- 數字通信同步技術的MATLAB與FPGA實現:Altera/Verilog版(第2版)
- 2018網信發展報告
- C/C++串口通信:典型應用實例編程實踐
- CCNP TSHOOT(642-832)認證考試指南
- 2小時讀懂物聯網
- 互聯網+思維與創新:通往未來的+號
- React Cookbook