Michal Bacik
10/29/2019, 8:24 PMcurrentComposer
used; this is probably referenced by the Compose plugin as it transforms @Composable functions. (global variables are evil 😉 )
Wouldn't it be better to omit magic code transformations, and follow style of Kotlin coroutines which are implemented purely as library (except of compiler suspend
keyword)? Coroutine builders pass CoroutineScope
as receiver parameter to body of couroutine, and there is no hidden magic behind this, we can study all state of coroutine in debugger.
Instead of global currentComposer
variable, Compose would work on a composer build state as normal reveicer variable into @Composable
function .
Do Compose designers fear that developers would mess with the build state and make more mistakes, or want hide implementation, or what's purpose of this rather complicated implementation wich needs special plugin and reworked Kotlin compiler?@Composable
marked functions, for now it looks like black magic 🙂
Kotlin developers explained in one video what's behind scenes of their coroutines, since then I understood it.
Maybe one day you can make similar explanation video what truly happens with the code of @Composable
funcs (e.g. there's invisible injected builder, or such).Michal Bacik
10/29/2019, 8:50 PMFudge
10/29/2019, 10:29 PMLeland Richardson [G]
10/29/2019, 11:21 PM