https://kotlinlang.org logo
#compose
Title
# compose
v

Vinay Gaba

09/20/2020, 5:03 PM
In the “Composable functions can run in parallel” section (https://developer.android.com/jetpack/compose/mental-model#parallel), I just noticed something
Because of this, writes like this are not supported in Compose; by prohibiting those writes, we allow the framework to change threads to execute composable lambdas.
I was wondering what “prohibiting those writes” means? Like I understand why we shouldn’t do it but how is the system enforcing it right now? I don’t see anything that’s stopping me from doing that.
👀 2
a

Adam Powell

09/20/2020, 6:59 PM
It doesn't yet, but we've got making this a compiler error on the todo list
👍 1
👍🏼 2
It doesn't even need multi threading to be wrong code either
Consider that the row and column in the example can recompose independently whenever the system likes
v

Vinay Gaba

09/20/2020, 7:11 PM
Thanks for adding more context! Yeah that does make sense. Will be very interesting to see how we can use compiler errors to avoid common mistakes 👍🏼
41 Views