Skip to content
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

Advanced navigation patterns #767

Closed
agundermann opened this issue Feb 4, 2015 · 5 comments
Closed

Advanced navigation patterns #767

agundermann opened this issue Feb 4, 2015 · 5 comments

Comments

@agundermann
Copy link
Contributor

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 active
  • state.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

@natew
Copy link
Contributor

natew commented Feb 4, 2015

Using the RouteHandler mixin you have some ability to implement a few of these functions. I started working on some similar stuff here: https://github.com/reapp/reapp-platform/blob/master/src/mixins/RoutedViewListMixin.js

I agree, the more logic we can put into the navigation mixin, the better. Just need the community to come up with some pull requests.

@stefanfisk
Copy link

@natew your link is dead :(

@natew
Copy link
Contributor

natew commented Feb 20, 2015

mjackson added a commit that referenced this issue Feb 27, 2015
Please note: this commit is still a work in progress!

All history objects subclass History and support 2 main methods:

- pushState(state, path)
- replaceState(state, path)

This API more closely matches the HTML5 history API, with the notable
omission of the title argument which is currently ignored in all major
browsers. It provides the user with the ability to store state specific
to the current invocation of the current URL without storing that data
in the URL itself. However, history objects that do not use the HTML5
history API (HashHistory and RefreshHistory) store their state ID in
the query string.

This should help with #767 and #828.

This work was inspired by work done by @taurose in #843 and @insin
in #828.
@ryanflorence
Copy link
Member

@taurose let me know if we need to reopen this

@christophediprima
Copy link

Could you please reopen it ? History.go() and History.state needed ! Is it something that is planed ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants