https://kotlinlang.org logo
#coroutines
Title
# coroutines
e

Erik Dreyer

08/25/2021, 3:04 PM
This might be more of a Spring Webflux question, but here goes… Say I have this controller method
Copy code
@PostMapping(path = ["/foo"])
  suspend fun example(): Flow<String> {
    val flux: Flux<String> = service.returnsFlux()
    return flux // <-- how to convert to Flow?
  }
(this is a trivial example, but I have an API that returns a
FLux<T>
) I’m trying to figure out how to go from a
Mono/Flux
back to the kotlin coroutines approach for Spring Webflux. I’d appreciate any help .
e

Erik Dreyer

08/25/2021, 3:29 PM
Thanks! In the case of
Mono
, is it still appropriate to call
mono.asFlow()
or is there a better way to handle Mono’s?
i

Ivan Pavlov

08/25/2021, 3:31 PM
Not sure, but I think you can use awaitFirst or similar to convert it to a value
👍 2
5 Views