https://kotlinlang.org logo
Title
e

elizarov

10/26/2017, 8:29 AM
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:
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

eddie

10/26/2017, 7:53 PM
Just curious, but how much overhead would there be in chaining builders like this, @elizarov?
e

elizarov

10/26/2017, 8:57 PM
Compared to what?
e

eddie

10/26/2017, 10:48 PM
Compared to directly running
next
within the coroutine preceding it?
e

elizarov

10/27/2017, 9:31 AM
A few more objects. I think < 100 bytes in total