-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retrieving data from replaced entries #41
Comments
The only other case where they got lost is if they're in the forward stack, or in most browsers if it's evicted by the back stack growing too long (I believe the limit is 40). I think the dispose event helps to find out when this happens though, so it's not a major concern. Another possible solution is to identify in the dispose event that it was a replace, rather than an evict, which would allow you to grab a handle on the entry (and state) that's replacing yours. |
This gives insight into any "ongoing" navigation, i.e. a navigation that hasn't yet reached navigationsuccess/navigationerror because the promise passed to respondWith() has not yet settled. Additionally: * Removes the finished property from every AppHistoryEntry, which is nice because it only ever really made sense on the current entry; it was about the transition. Instead, the presence or nullness of appHistory.transition can be used. * Adds a type property to AppHistoryNavigateEvent since we're going to have it on appHistory.transition anyway so having it earlier (before respondWith() is called) seems very reasonable. Closes #86. Closes #11 by adding the appHistory.transition.finished promise. Helps with #41 as you can retrieve data from the replaced entry, at least during the transition, with appHistory.transition.previous. Probably helps with #14 (although currentchange needs a bit of an overhaul) since appHistory.transition has the sort of useful information discussed there, such as the previous entry or the type of navigation.
This gives insight into any "ongoing" navigation, i.e. a navigation that hasn't yet reached navigationsuccess/navigationerror because the promise passed to respondWith() has not yet settled. Additionally: * Removes the finished property from every AppHistoryEntry, which is nice because it only ever really made sense on the current entry; it was about the transition. Instead, the presence or nullness of appHistory.transition can be used. * Adds a type property to AppHistoryNavigateEvent since we're going to have it on appHistory.transition anyway so having it earlier (before respondWith() is called) seems very reasonable. Closes #86. Closes #11 by adding the appHistory.transition.finished promise. Helps with #41 as you can retrieve data from the replaced entry, at least during the transition, with appHistory.transition.from. Probably helps with #14 (although currentchange needs a bit of an overhaul) since appHistory.transition has the sort of useful information discussed there, such as the previous entry or the type of navigation.
A nice feature of the navigation API is that (unless we implement #9) data is almost never "lost". This solves a lot of problems we hear about today where
history.state
is unreliable, or there's no way to easily know what your previous history entry was without keeping a side table, etc.However, there is one place in the current design where data can be lost: if you use
navigation.navigate(url, { replace: true })
,history.replaceState()
, orlocation.replace()
, the current navigation API history entry data disappears.I say "kind of" because object references get replaced, not updated. So you could have a reference to the old
NavigationHistoryEntry
object, which would allow you to accessurl
andgetState()
. (But it's no longer inappHistory.entries()
.)We could pretty easily keep these replaced
NavigationHistoryEntry
s around and expose them. For example:Each app history entry could have a
replaced
property that is null, or the entry it replaced. (This allows potentially chaining, e.g.navigation.currentEntry.replaced.replaced.replaced
.) This lets you access them forever. (Is this a problem for memory usage?)The
currententrychange
event could have areplaced
property which contains the replacedNavigationHistoryEntry
. This lets unrelated parts of the code (i.e., not the code doingnavigation.navigate(, { replace: true })
) grab important data as necessary.The text was updated successfully, but these errors were encountered: