spring-framework / org.springframework.web.reactive.function / BodyExtractors / toFlux

toFlux

open static fun <T : Any> toFlux(elementClass: Class<out T>): BodyExtractor<Flux<T>, ReactiveHttpInputMessage>

Return a BodyExtractor that reads into a Reactor Flux.

Parameters

elementClass - the class of element in the Flux

- the element type

Return
a BodyExtractor that reads a flux

open static fun <T : Any> toFlux(typeReference: ParameterizedTypeReference<T>): BodyExtractor<Flux<T>, ReactiveHttpInputMessage>

Return a BodyExtractor that reads into a Reactor Flux. The given ParameterizedTypeReference is used to pass generic type information, for instance when using the org.springframework.web.reactive.function.client.WebClient

 Flux<ServerSentEvent<String>> body = this.webClient .get() .uri("http://example.com") .exchange() .flatMap(r -> r.body(toFlux(new ParameterizedTypeReference<ServerSentEvent<String>>() {}))); 

Parameters

typeReference - a reference to the type of element in the Flux

- the element type

Return
a BodyExtractor that reads a flux