For further actions, you may consider blocking this person and/or reporting abuse
Read next
Most underrated Flutter property "autofillHints"
Shajin KP -
React Native 0.76: The New Architecture That Takes Performance and Efficiency to the Next Level 🚀
Abdulnasır Olcan -
A Guide to Upgrade Your React Native Project to the New Architecture
Ajmal Hasan -
Handling Notifee Push Notifications in React Native (Display & Click)
Ajmal Hasan -
Top comments (11)
Isn't that something compose is already doing? for example when you have a
LaunchedEffect
& any other composable as children of parent composable, AFAIK they will be executed in parallel:From my experience with compose I will say that LaunchedEffect & Box will be executed in parallel
That’s true, and my wording wasn’t as precise as it should have been. You are correct that effects can already be used to run code in parallel to composition.
What I intended that sentence to mean was that Compose can perform composition of multiple composables in parallel. It does not currently do this - when preparing a frame, all invalidated composable functions are currently recomposed in a loop on the main thread. Experimental support for parallel recomposition is already present but you have to opt in to it using fairly low level APIs.
So, for example, in this code, when
state
is changed, the lambdas passed to box 1 and box 2 would both be invalidated, and then they could both be re-executed on different background threads. Right now they’d be executed serially on the main thread.Oh! Thanks for clarifying, I got it. I can imagine how powerful this technique could be
Should we use Compose state management outside of presentation layer? I mean some stateful observable objects in domain or data layers.
I don't personally have a strong opinion here. If it makes sense, and it makes the code cleaner/more testable/easier to maintain, then sure.
This is a very interesting idea. What might that look like? Can you elaborate a bit more? I imagine this would replace either RxJava or Flow on these lower layers.
Should we use mutableStateOf in ViewModels? Official documentation recommends to use LiveData or StateFlow for some reason: developer.android.com/jetpack/comp...
It depends how much you want to couple your ViewModels to the Compose runtime and mental model. I do wish the snapshot stuff was in a separate artifact so this would be an easier call. I would see no reason to not use snapshot state in view models in a 100% compose app. I also think that in such an app, "view model" is basically interchangeable with/just another word for "hoisted state class".
What are you referring to as "glue code"?
Thanks!
Re-reading the post more closely, is this the answer to my question?
Is "glue code" generic infrastructure code to make any state observable?
Some comments may only be visible to logged-in visitors. Sign in to view all comments.