ritesh
03/13/2022, 2:33 AMStable
- as they are declared immutable.
When declaring a data class or a class which can hold an Immutable
as data-structures are not Stable by default?
Or compose compiler can infer?
@Immutable
data class MyClass {
val someId:Int,
val myList:List<SomeClass>
}
Adam Powell
03/13/2022, 2:45 AMList
is read-only, not immutable.ritesh
03/13/2022, 3:01 AMImmutable
as list isn't (it's read-only), but at my end the List
reference is always going to be same but the value it's holding can be a different instance over the time or modify few of its properties, that can/should end-up re-composing only that row/column if it's inside a LazyColumn
or LazyRow
Michael Paus
03/13/2022, 2:48 PM.collectAsState()
there could be a parameter where I could tell Compose that the state in question can be treated as stable/immutable. The @Stable
annotation is also just a promise which is technically neither validated nor enforced.Adam Powell
03/13/2022, 3:08 PMritesh
03/13/2022, 3:23 PMArun Joseph
03/13/2022, 4:04 PMStateFlow
for ui state and use state.copy(property = something).emit()
for state updates. So I think this might cause problems. Is there any trick to wrap collectAsState
to tell that it is @Immutable
?Adam Powell
03/13/2022, 6:12 PMritesh
03/13/2022, 6:27 PMStableMarker
adhering to the same contractAdam Powell
03/13/2022, 9:10 PMritesh
03/14/2022, 2:22 PM