<@UHAJKUSTU> I have this piece of code ```runCatch...
# decompose
v
@Arkadii Ivanov I have this piece of code
Copy code
runCatching { 
    navigator.pushNew(screen) 
}.onFailure {
    if (it.message == "Configurations must be unique") navigator.bringToFront(screen)
}
Now I have screens in backstack like A -> B Now, if i go from B to A, nothing is happening And when i press back button while being in B, it goes back to A and the whole UI freezes and if I press back again, the back stack behaves weirdly,
a
There are multiple issues with the code. 1. Navigation exceptions are not supposed to be recoverable. The router may be left in an inconsistent state. We should avoid navigation errors at all costs, and treat them as fatal. 2. In some rare cases the navigation can be performed asynchronously, and so the
onFailure
callback won't be called at all. 3. The next alpha version of Decompose will introduce
pushToFront
function, which is probably what you need? 4. In the meantime you can copy it from here.
v
Thanks a lot
@Arkadii Ivanov would this replace if the same config is at the top of stack or just ignore adding it like
pushNew
?
a
Though, this particular check is currently performed in the very beginning, so I guess it shouldn't cause any issues.
It will ignore and do nothing. Replacing a config object with another that is equal is essentially a no-op operation.
v
Okay, thanks
a
FYI,
pushToFront
is released in Decompose 3.0.0-alpha05.