https://kotlinlang.org logo
#coroutines
Title
# coroutines
e

elizarov

06/27/2017, 8:23 AM
@louiscad I’d recommend the following workaround for your use-case in your fragment code:
Copy code
val mapAsync = async(context, CoroutineStart.LAZY) { ... your async code here to get the map ...  }
Then you’d use it like this
fragment.mapAsync.await()
. It is not as clean as property delegate, but works just as fine (100% lazy and remembers the value after initialization)
👍🏽 2
k

kevinherron

06/27/2017, 1:22 PM
elizarov: is this operation atomic?
e

elizarov

06/27/2017, 2:09 PM
@kevinherron Which operation?
await
- yes. It will start this coroutine exactly once even if multiple concurrent
await
are invoked
k

kevinherron

06/27/2017, 2:19 PM
Yes, that’s what I meant. Just ensuring the async block won’t run more than once if accessed concurrently the first time.