In `Nav3` ```fun <T : NavKey> NavBackStack<T>.pus...
# compose
u
In
Nav3
Copy code
fun <T : NavKey> NavBackStack<T>.push(navKey: T) {
    if (!contains(navKey)) {
        add(navKey)
    }
}
should this be wrapped in
Snapshot.withMutableSnapshot { .. }
?
p
I see only one mutating operation so I don't think so
u
ismt it then "check then act" problem?
p
I don't think that problem applies here. withMutableSnapshot is basically to make many updates to the state but triggering only one recomposition. In this case there is only one update to the state
👆 1
u
I see
m
@Pablichjenkov You’re supposed to use
withMutableSnapshot
to group multiple updates into one recomposition? May I have the source please?
p
Well, I didn't say you are supposed to, all the time. I said worst case, if you make updates to a snapshot state from a thread that is not main. You can group them to avoid multiple recompositions. Official documentation
u
I use them always because of upcoming resumable recompositions feature (or whatever its called)
👍 1
p
Makes a lot of sense too