im working with an async library that returns a Co...
# announcements
im working with an async library that returns a CompletableFuture; how could i convert it into a coroutine? (like Mono.fromFuture() does)
@Adam Powell yes, that is useful, but what if I don't want to await it yet?
what if i want await to run in another layer?
are you asking how to get a
from it? (the
method documented on that page?)
that's it, thank you
­čĹŹ 1
still new to this so im lost on some keywords like deferred, too used to javascript async
@Adam Powell last question, what if you want to do something on a deferred function once its done, without actively awaiting it?
like an .onComplete{ println(it) }
if that's what you're looking to do, I don't think you want to convert it to a
after all. It sounds like you want something more like:
Copy code
launch {
  val result = future.await()
but in that case you're awaiting for it on that step
i don't want to actively await it, just that once it completes it does something in particular with it
so that if the caller of the function actively awaits for it, then the data structure it receives will be what i expect it to be
an example in pseudocode:
Copy code
fun parentFunction(){
  val test = childFunction.await()
  return test + test

fun childFunction(){
  (outside function that i have no control of).onComplete{ it.toNumber() }
that is not the idiomatic way to use coroutines. Suspend functions naturally await their results. The
extension brings
usage into this model so that you can expose
functions to the rest of your code and use the structured concurrency model.
If a caller does not want to actively await the result of a suspend function, it is up to that caller to
launch {}
async {}
alright, thank you