-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Description
I think it would be great to offer some advanced navigation functionality such as:
canGoBack()canGo(n)go(n)// n positive or negative, like with history.go(n)canGoBackTo(name, params, query)goBackTo(name, params, query)// goes back to when the route was last activestate.historyId// e.g. for caching stuff based on current history entry like form data, or choosing animations by comparing to previous state
This could also be very useful for implementing up navigation in Android.
While this seems trivial to implement for in memory locations (for react-native), in my opionion it would also be great to have this for web apps. I've actually played around with this in the past, and I think it might actually be possible to make this happen for HistoryLocation by managing a counter within the history state object. I don't think it's possible with HashLocation or RefreshLocation though.
Implementation-wise there's also the problem of how to provide persistency (hitting refresh button, closing browser), but I first wanted to hear what you think about this API.
On a related note, the current goBack() doesn't play well when using browser navigation. With this kind of approach, it should be possible to make it work reliably.
Related #765