-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Describe the problem
The new shallow routing feature is pretty useful, but one thing I've just stumbled into and was surprised by is the fact that calling invalidate
or invalidateAll
, in addition to re-running the load
functions, also clears $page.state
(that means it destroys any "shallow routes" that might've been set); and it doesn't create a new history entry either, which is extra weird, it means the current history entry will still remain associated with the $page.state
prior to the invalidateAll
call, but the $page.state
itself will be empty; causing a mismatch.
This can be undesirable. Sometimes you only want to re-run the load
functions, that's it, the $page.state
being emptied could be an unpleasant side-effect.
If someone wants to clear the $page.state
as well, they could do so by simply invoking pushState({})
right afterwards. There's no reason for invalidateAll
to do that internally, while not allowing the developer to choose whether they want that or not.
Describe the proposed solution
Either change the default behavior (I suspect this wasn't actually thought through, but feel free to correct me), or if this was somehow intended, at least add an option to invalidate
and invalidateAll
that leaves decision about whether they want to preserve the page state or not up to the developer:
invalidateAll({
preserveState: true
});
Alternatives considered
No workarounds I could come up with, at the moment. Which is a big bummer.
Importance
severe
Additional Information
No response