Is there still no plans in supporting suspendable ...
# coroutines
r
Is there still no plans in supporting suspendable properties/delegates (https://youtrack.jetbrains.com/issue/KT-15555) ?
e
This does not answer your question, but this thread (https://kotlinlang.slack.com/archives/C1CFAFJSK/p1591261760079000) has some good discussion points on the subject
One conclusion from the thread: there's
CoroutineScope.async {}
to produce a
Deferred<T>
that you can
await()
. That is already a quite flexible way to encapsulate an asynchronous result.
r
It's good if you are just writing plain old code, but not if you are building DSLs. Having to call
await
is clunky. My use case is in spek:
Copy code
val m by memoized { ... }

// it block is a suspending block
it("doSomething") { f.doSomething() }
it("doAnother") { f.doAnother() }
I'm currently working on adding coroutine support in Spek, Each
it
will receive a unique instance of
f
and one improvement I want to do is to allow the two `it`s to be run in parallel. At the moment, the delegate that is backing
f
tracks the instance, I can't really make the two `it`s run in parallel as they share state. What I want to achieve is to store the state in the
coroutineContext
.
that it means the two its can run independently.