Mono vs Flux in Reactive Stream

前端 未结 3 2100
闹比i
闹比i 2020-12-24 01:10

As per the documentation:

Flux is a stream which can emit 0..N elements:

Flux fl = Flux.just(\"a\", \"b\",         


        
3条回答
  •  無奈伤痛
    2020-12-24 01:28

    From the docs here

    This distinction carries a bit of semantic information into the type, indicating the rough cardinality of the asynchronous processing. For instance, an HTTP request produces only one response, so there is not much sense in doing a count operation. Expressing the result of such an HTTP call as a Mono thus makes more sense than expressing it as a Flux, as it offers only operators that are relevant to a context of zero items or one item.

提交回复
热议问题