Edoardo Luppi
08/08/2024, 11:49 AMCoroutineScope.future(...).
Internally future(...) uses a CompletableFutureCoroutine which overrides onCompleted and onCancelled to be notified and complete or cancel the Future.
In the JS world the CoroutineScope.promise(...) function first calls async(...) to get a Deferred value, and then listen for its completion via invokeOnCompletion.
Why this implementation difference and not create a PromiseCoroutine in the same way as CompletableFutureCoroutine?Edoardo Luppi
08/08/2024, 11:53 AMpromise.asDynamic().deferred = this
which can then be used in Promise<T>.asDeferred()?
Still have to encounter a place where that is useful, but it's just me obviously.Sam
08/09/2024, 7:12 AMpromise() appears to allow lazy start, while future() doesn't. But that just makes me more confused, to be honest.Sam
08/09/2024, 7:13 AMEdoardo Luppi
08/09/2024, 7:34 AMPromiseCoroutine I shaved off 5 kb from the outputted coroutines JS file.Edoardo Luppi
08/09/2024, 7:37 AMinvokeOnCompletion is less performant than simply implementing the two Coroutine functions. It seems more involved for sure, both in logic and on the amount of instantiated objects.Edoardo Luppi
08/09/2024, 7:39 AM