`invokeOnCompletion` is mostly designed for intern...
# coroutines
e
invokeOnCompletion
is mostly designed for internal machinery. Franky, I think it should be somehow “hidden” from API to discourage its use from a general-purpose application code, but I don’t know what would be best way to do it. You should define
then
to get this “chained” style of programming like this:
Copy code
fun <T, U> Deferred<T>.then(next: suspend (T) -> U): Deferred<U> = async { next(await()) }
We might include it in the future updates of
kotlinx.coroutines
for convenience.
👍 1
e
Just curious, but how much overhead would there be in chaining builders like this, @elizarov?
e
Compared to what?
e
Compared to directly running
next
within the coroutine preceding it?
e
A few more objects. I think < 100 bytes in total