collectList() gathers every element emitted by a Flux and returns a Mono containing those elements in a List. section 11.3.3
Collecting fruit
Flux.just("apple", "orange", "banana", "kiwi", "strawberry") produces a Mono<List<String>> through collectList(). StepVerifier checks that the Mono emits the complete fruit list and then completes. section 11.3.3
Use collectList() when the entire stream should become one collection:
- It emits one List from the source Flux through a Mono, unlike buffer(), which produces a Flux of lists. section 11.3.3
- Use collectMap() instead when elements should be gathered into a Map using calculated keys. section 11.3.3
Figure 11.19 The collectList() operation results in a Mono containing a list of all messages emitted by the incoming Flux.
Shows the resulting Mono containing a List of all messages emitted by the incoming Flux. section 11.3.3
