Immutable Collection prevent composition many times even if required
I need to draw polylines
if I pass List<LatLng> it's fine but recomposing unnecessarily
https://user-images.githubusercontent.com/54987308/231945860-6d484479-51b3-41c4-9d0f-edb1875f887d.mov
if I pass `ImmutableListhttps://user-images.githubusercontent.com/54987308/231947188-6521e465-a799-48d0-8d08-c5c6f7f7ec6d.mov
If you would like to upvote the priority of this issue, please comment below or react with :+1: so we can see what is popular when we triage.
@pseudoankit Thank you for opening this issue. 🙏 Please check out these other resources that might help you get to a resolution in the meantime:
- Check the issue tracker - bugs and feature requests for Google Maps Platform APIs and SDKs
- Open a support case - Get 1:1 support in Cloud Console.
- Discord - chat with other developers
-
StackOverflow - use the
google-mapstag
This is an automated message, feel free to ignore.
Update : Even if we mark data class with @Stable then also many times it skips composition
Update 2: got some workaround
wrapping the compose method with key block and providing the list as key seems to work
when using ImmutableCollection
data class Polyline(val latLngs : ImmutableList<LatLng>)
val mapPolylineList = persistentListOf<Polyline>()
key(mapPolylineList) {
PlotPolyline(mapPolyline = mapPolylineList)
}
Update 2: got some workaround wrapping the compose method with
keyblock and providing the list as key seems to work when usingImmutableCollectiondata class Polyline(val latLngs : ImmutableList<LatLng>) val mapPolylineList = persistentListOf<Polyline>() key(mapPolylineList) { PlotPolyline(mapPolyline = mapPolylineList) }
Any explanation on how this works ??
@GaneshShetty951 it's does exactly same how having parms in composable works but for some reasons composable annotated with @GoogeMapsCompose was not behaving correctly so key block also does the same if value changes then only it will recompose it's block
Exact same behavior with Marker.
Using ImmutableCollection does not trigger a recomposition of Marker which causes some markers to not appear