dave08
11/08/2022, 1:03 PMremember {} or mutableStateOf() inside state holders... or whether the one surrounding the object itself is enough....?PHondogo
11/08/2022, 1:13 PMgildor
11/08/2022, 1:24 PMdave08
11/08/2022, 1:29 PMdave08
11/08/2022, 1:53 PMmutableStateOf...dave08
11/08/2022, 1:56 PMremember { mutableStateOf<MyStateHolder>(MyStateHolder()) } needs to be used there even though inside it there might be some `mutableStateOf()`s for mutable properties?gildor
11/08/2022, 2:52 PMStylianos Gakis
11/08/2022, 4:09 PMremember or not.
It’s simply a matter of if you’re inside a composable function or not. If you are, you have to think that whatever you’re calling can and will potentially be called many times a second. If you do val x = Foo() inside the context of a @Composable function, Foo() will be re-called on every recomposition and therefore if you’re saving anything in there, it will be overwritten.
If you are not inside a composable function then you just never need remember. Hence the examples where inside plain classes you can just do mutableStateOf directly.
That’s how I like to think about it at least.dave08
11/08/2022, 4:16 PM