<@U2SKJHSGK> Disclaimer: I’m not sure we can actua...
# language-proposals
@miha-x64 Disclaimer: I’m not sure we can actually get
val v by asyncLazy { … }
working in 1.1 time-frame, but the simpler syntax of
val v = asyncLazy { … }
is already working in 1.1-M04. The only downside is that you have to use
instead of just
. When the former syntax
by asyncLazy
becomes possible, this property will have a suspending getter and every attempt to read this property will have to be inside a coroutine. However, if you are not in a coroutine, it is always easy to create one (that is the whole point of coroutines — they are extremely lightweight) and this gives you call-site visibility on what your actual asynchronity policy is. For example, if you are not in a coroutine and you want to read
value and you want to block your thread while it is being computed, you just do
blocking { v }
blocking { v.value() }
for now). This way that fact that you are actually blocking a thread becomes explicit. Compare this to regular
properties where thread-blocking is implicit and invisible side-effect that can potentially bite you on such an innocent-looking action as reading a property.
👍 10