zak.taccardi
07/29/2019, 6:42 PMsuspend () -> T
2. Deferred<T>
Vote 1️⃣ for suspend fun () -> T
or 2️⃣ for Deferred<T>
zak.taccardi
07/29/2019, 6:43 PMsuspend () -> T
as a more abstract approach, but it requires more boilerplate + some extra anonymous classeszak.taccardi
07/29/2019, 6:44 PMDeferred<T>
has a lot less boilerplate to implement, more clearly indicates that the value will be cached, but it exposes its underlying Job
API, which a caller could accidentally canceloctylFractal
07/29/2019, 6:45 PMCompletableDeferred
that's not part of the job.zak.taccardi
07/29/2019, 6:46 PMCompletableDeferred
extends Deferred
so it’s worse. This isn’t an API that you would want to allow callers to be able to complete. It’s read onlyoctylFractal
07/29/2019, 6:46 PMoctylFractal
07/29/2019, 6:47 PMDeferred<T>
, but internally you would hand-off the value to create a gapzak.taccardi
07/29/2019, 6:47 PMDominaezzz
07/29/2019, 7:36 PMzak.taccardi
07/30/2019, 12:25 AMlouiscad
07/30/2019, 2:59 PMSuspendLazy
type: https://github.com/LouisCAD/Splitties/blob/develop/modules/coroutines/src/commonMain/kotlin/splitties/coroutines/SuspendLazy.kt
https://github.com/LouisCAD/Splitties/blob/develop/modules/coroutines/src/jvmMain/kotlin/splitties/coroutines/SuspendLazyJVM.ktzak.taccardi
07/30/2019, 3:00 PMlouiscad
07/30/2019, 10:58 PMval
private, and make a top level suspending function getting the value from it.