Hey! :wave: I’m migrating a design system that imp...
# compose
n
Hey! 👋 I’m migrating a design system that implements a lot of components to Compose. Since this work is hard and long, I started by using some
AndroidView
to wrap up the traditional view components. I’m using the
update
lambda to make the needed adjustments in the view whenever the state changes. Is there a way to only set the properties that changed for real? If I just set everything that comes as parameter of the composable, they are all reset each time one of them changes. For example, if the text on a TextView changes, the TextAppearance is set again. Thanks! 🙇
c
Compose will skip recompositions if your input does not change. It is possible that you have to annotate your classes in order to achieve this. See more here.
n
But if one of the inputs does change, it will run the whole
update
lambda of
AndroidView
, right?
c
That is correct. If it’s really a problem, you can cache the previous state in
remember { mutableStateOf() }
and check if it’s still the same or not.
👍 1
n
Ok, that makes sense. I was wondering if there was some automatic way to do it. But it’s good enough for now. Thanks! 🙂
l
Also, there is one with skippableUpdate, maybe, at least with emit(which AndroidView uses) I don't know AndroidView also has it though..