Let's say we have a function
suspend fun doSomething(value: Int): String {
delay(1000L)
return "abc_$value"
}
How to convert it to a function returning Mono
? Are there any hidden problems with switching between threads belonging to coroutine scope and reactor event loop threads?
fun resultAsMono(fn: suspend (Int) -> String): (Int) -> Mono<String> {
// ???
}
So that effect would be like this:
val newFn = resultAsMono(::doSomething)
val result = newFn(5).block()
assertThat(result).isEqualTo("abc_5")