I know this topic may be a bit “controversial”, but I was wondering if the router in vNext will support some kind of stack functionality. As far as I know the current implementation doesn’t have that kind of feature. If I’m wrong and there is a way of doing this, please let me know
Let me explain what I mean:
When navigating from one route to another there should be some kind of option to decide whether the current view will be kept in background and the new view will “overlay” the old one or whether the stack will be cleaned before.
To be more specific:
Imagine you are in a search-view where you entered multiple search criterias. You see multiple search results and click one and so navigate to the detail-view of this record. Now you find out that you’ve clicked to wrong one. You navigate back to the search-view. Now you have to enter the search criteria once again … In this case it would be great if the router just removes the detail-view and shows the search-view, which was kept in background, again.
To prevent that the stack will increase infinite there could be a max stack size …
thanks for your answer. As far as I understand the router activation strategy, it’s not quite what I want.
I forgot to write in the ticket that it should also be possible to open a view multiple times (although of course max. one view is currently visible). If the user clicks back in the browser, this view should be disposed. Or if a corresponding navigation is executed, which resets the stack, then all views should be disposed.
@stefan I’m sure what you’re describing is how the router currently works. The stack you’re describing is the browser history and the router already uses this.
When navigating away from a view/view-model, its current state is destroyed. Instead of destroying it, @stefan would like the ability to save it on a stack so the user can navigate back and see the same view/view-model state.
@stefan The vCurrent router doesn’t have quite what you want although this PR would help make it possible.
For the vNext router, however, there are plans to support “stateful components” from early on. The stacking behavior you describe would be a setting for how the component cache would behave.
You can find a (still slightly buggy) demo here – instructions are in blue on the first page – and some other vNext router demos here.