Pablo
02/19/2025, 9:32 PMdata class mapState(
val hasLocationPermission: Boolean = false,
val userLocation: LatLng? = null,
val loadingArrivalTimes: Boolean = false,
val busStops: List<BusStop> = emptyList(),
[...various data more...]
)
private val _mapState = MutableStateFlow(MapState())
val mapState: StateFlow<MapState> = _mapState
If I change something on for example "busStops" using update/copy on _uiState... will every composable in which the full mapState object is passed be recomposed even if other variables are used and not "busStops"? if so, which is the recommended approach to avoid this?Darshan Parajuli
02/19/2025, 9:50 PMMichael Krussel
02/19/2025, 10:43 PMbusStops
list is not considered immutable and functions taking in mapState
are not skippable.
But the general way to reduce things are to have the function that uses the whole state object delegate to other composable functions that take less of the state. Then those functions can be skipped if they don't use the part of the state that changed.Pablo
02/20/2025, 9:30 AMStylianos Gakis
02/20/2025, 9:34 AM