ursus
03/01/2026, 11:14 PMnav3
val backstack = rememberNavBackstack()
// Bring to top
val index = backstack.indexOf(Foo)
if index > 0
val foo = backstack.removeAt(index)
backstack.add(foo)
This seems to work for reordering existing screen to top of backstack - but, doesn’t it technically remove the screen for a split second - possibly triggering disposal callbacks and others?
Or is backstack “applied” only at vsync time?tad
03/01/2026, 11:21 PMbackstack , assuming it is backed by snapshot state, are "applied" after composition and the new value is visible only to the next compositiontad
03/01/2026, 11:24 PMtad
03/01/2026, 11:27 PMursus
03/01/2026, 11:36 PMursus
03/01/2026, 11:38 PMursus
03/01/2026, 11:39 PMtad
03/01/2026, 11:58 PMSnapshot.withMutableSnapshot, that basically guards against other threads seeing the intermediate state before it's all applied.ursus
03/02/2026, 12:03 AMtad
03/02/2026, 12:03 AMursus
03/02/2026, 12:06 AMtad
03/02/2026, 12:22 AMtad
03/02/2026, 12:25 AMursus
03/02/2026, 12:35 AMWinson Chiu
03/02/2026, 12:57 AMwithMutableSnapshot anyways because it helps communicate to a reader that a change is transactional and expected to never recompose in the middle. And that way you don't need to worry about what thread it's invoked in.ursus
03/02/2026, 1:15 AM