-
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
Adding sugar for current index/can go back/can go forward #6
Comments
I do think we should add const canGoBack = appHistory.currentEntry.index !== 0;
const canGoForward = appHistory.currentEntry.index < appHistory.entries.length -1; Seems very reasonable to me, once we've added index to entries. |
From discussion @ slightlyoff/history_api#25:
I don't quite get the notion of a "current entry" in history.
|
Because you are always on a page. That page is the current entry. To have zero entries, you'd need to not be on a page, but then you wouldn't be able to run JavaScript.
The page you are on.
It's not clear exactly what you mean by this. |
Although it's pretty straightforward, I find the lack of symmetry in if (appHistory.current.index !== 0) {
await appHistory.back();
} a bit displeasing. if (appHistory.canGoBack) {
await appHistory.back();
} seems nicer to me... |
You know, I'm asking because ... If the current entry represents the current page, then a design may choose to use the So, instead of storing the state somewhere else and clone it in order to add it to the history using However, a deep clone operation is required anyway when calling That's why I'm asking about the notion of the current entry.
|
You may enjoy #17. |
Minor question: if your Similarly, if you're looking at the |
(Moved from slightlyoff/history_api#25 by @SetTrend, summarized by me.)
It's currently slightly awkward to determine the index of the current entry, and whether you can go back and forward:
It might be nice if this could be done with
or maybe we should add something to all the individual entries, like
A use case where this is especially important is when you want to show your own navigation UI, such as when you're a widget inside an iframe (where the browser navigation UI is not very related to your UI). @SetTrend's specific example was a multi-step form embedded in an iframe.
The text was updated successfully, but these errors were encountered: