12

I'm using Spring web-flux with Reactor and for me is not clear when RestController method should return

Mono <List<Object>> and when Flux<Object>.

Could you provide some case when to use each of them?


Flux<Object> indicates that new Object instances can be pushed in a reactive way at any point. With Mono<List<Object>>, you will get 1 time a value that is a list of objects, but that list will never change.

See also Mono vs Flux in Reactive Stream

4

1 回答 1

12

Flux<Object>表示Object可以在任何时候以反应方式推送新实例。使用Mono<List<Object>>,您将获得 1 次作为对象列表的值,但该列表永远不会改变。

另请参阅响应式流中的 Mono vs Flux

于 2018-10-24T09:34:24.147 回答