Repository navigation
Hand over states added to a mutableStateListOf in place - #22
Merged
Merged
Conversation
Markers, Circles, Polylines and Polygons handed their list to the map again only when given a different list. A mutableStateListOf that the app adds to stays the same list, so a pin-per-tap screen logged one more marker per tap and drew none. Each now also follows in-place changes to a SnapshotStateList, copying it on the main thread so the work on Dispatchers.Default never reads it while the app changes it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Markers(states),Circles(states),Polylines(states)andPolygons(states)re-ran their hand-over only when given a different list (LaunchedEffect(states)). AmutableStateListOfthe appadds to is the same list, so the added states never reached the map.Found running the Studio's "drop a pin where you tap" sample on an emulator: logcat printed
markers: 1,markers: 2, and no pin was drawn.Change
listVersions(list): the list now and, for aSnapshotStateList, again after each in-place change (snapshotFlow, a copy taken on the main thread). Other lists behave exactly as before (one emission per list).LaunchedEffect(states).Dispatchers.Defaultwork now reads a copy, never the liveSnapshotStateListthe app may be changing.Verified
InPlaceListTest: add/remove onmutableStateListOffor all four kinds reaches the collectors. Fails on develop, passes here.:android-sdk-compose:testDebugUnitTest,apiCheck(no public API change),assembleReleasein the aggregate build. ktlint: no new findings in changed/added files.