can recomposition be described in terms of Views like: `"recomposition is the process of removing al...
o
can recomposition be described in terms of Views like:
"recomposition is the process of removing all of the views on the screen > going over your code again > depending on state > adding different views to the screen"
?
it’s not like they’re being added ontop of each other is it, it’s like a reset of the UI but this time the deciders of what to show and what to hide are controlled by your state
c
I don’t think that’s quite correct. It’s more like it’s executing all of your
@Composable
code again, and intelligently deciding which functions can be skipped or need to be executed again because the data has changed. It’s decidedly not removing all views and recreating them, but selectively updating the attributes of the views that are already there. The end result is much the same as if you were to completely remove and replace your entire UI each frame as far as the programming model is concerned, but the technical “recomposition” process is much more optimized and efficient than truly removing and recreating all views.
o
that’s a good answer thank you
z
There are other parts of composition that have lifetimes (eg RememberObservers, effects) that survive across recompositions so the “everything is torn down and recreated” mental model kind of breaks down when trying to understand those.