<@UHAJKUSTU> as we have pushToFront(), which moves...
# decompose
v
@Arkadii Ivanov as we have pushToFront(), which moves the config to front if it has any, so app does not crash if config is already present Is there anything similar to replaceCurrent? I want that if there is same configuration in stack, then replace with that Or maybe someway to remove a specific config from stack
a
There is no out-of-the-box way. But you can create your own using
navigate {}
.
v
I see, so I can just add the config to the end and run a
.distinct()
on it maybe this
Copy code
navigator.navigate {
    it.filterNot { it == screen}
    .toMutableList()
    .apply {
        removeAt(lastIndex)
        add(screen)
    }
}
a
This will crash if the stack has the only item equal to the new configuration. Try this:
it.dropLast(1) - screen + screen
v
This works, thanks
decompose intensifies 1