ursus
04/30/2026, 10:18 PMNav3 I want to scope a instance to group of navkeys, and I need a explicit removal callback once last of the group was removed
class SandboxScopeDecorator(
private val backStack: List<NavKey>,
private val onSandboxRemoved: () -> Unit,
) : NavEntryDecorator<NavKey>(
onPop = { poppedKey ->
if (backStack.none { key -> key is SandboxKey }) {
onSandboxRemoved()
}
},
)
How does this look? Is it a good idea to pass in the backstack into decorator? Or does this belong somewhere else?efemoney
05/02/2026, 5:19 AMefemoney
05/02/2026, 6:19 AMA1 B1 A2 A3 C1 B2
There will be group keys A, B & C and A will only be removed when all the A entries are popped off the stackursus
05/02/2026, 7:57 AMefemoney
05/02/2026, 8:07 AMefemoney
05/02/2026, 8:07 AMursus
05/02/2026, 8:18 AMefemoney
05/02/2026, 8:20 AMursus
05/02/2026, 8:21 AMursus
05/02/2026, 8:46 AMif key == A1 then begin else if key == B2 then complete but I fear this is too brittle over time. Is this what you do?efemoney
05/02/2026, 8:50 AMursus
05/02/2026, 8:52 AMmaybeClearursus
05/02/2026, 8:53 AMefemoney
05/02/2026, 9:12 AMursus
05/02/2026, 9:19 AMursus
05/02/2026, 9:58 AMentry.groupKey() is a extension inputting metadata right?efemoney
05/02/2026, 10:44 AMursus
05/02/2026, 10:50 AMefemoney
05/02/2026, 11:40 AMursus
05/02/2026, 11:53 AMefemoney
05/02/2026, 12:12 PMcontentKey is completely removed from the backstack. Simple.
Its with the guarantee above that I base my solution.ursus
05/03/2026, 8:45 AMrememberSaveable somehow.
With the nested navdisplay approach I had I simply had a central place where to create the graph instance, and above it kept the saved state and then synced them in SideEffect (so the saved value always has the latest in memory state, so it can pass it into the factory of the graph come process restore time)
But now, since this new decorator approach is global - where would you keep track of the in memory state to save?