-
Notifications
You must be signed in to change notification settings - Fork 5
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
Navigations while a navigation is ongoing: Does async make sense? #22
Comments
I don't really understand the question. It's because they're asynchronous, that serializing them is necessary. The alternative, of running them in parallel, seems really bad---it'd just be a race to see who finishes first, or maybe both of them could finish!
I'm not sure what this means. Could you give a code example? |
I see, let me explain: I would make calls to For the following reasons:
|
I see. Your proposal goes against one of the main goals of this proposal, which is to make asynchronous navigation (i.e., fetching the appropriate data from the server, performing potentially-asynchronous component initialization, etc.) a first-class part of the history API and navigation lifecycle. See more discussion in https://github.com/slightlyoff/history_api/blob/master/app_history.md#goals and https://github.com/slightlyoff/history_api/blob/master/app_history.md#measuring-standardized-single-page-navigations |
I can't find asynchronous as one of the goals in this list. Wouldn't it suffice to just run |
Did you read https://github.com/slightlyoff/history_api/blob/master/app_history.md#measuring-standardized-single-page-navigations ? In particular, giving the browser---and the rest of the app---an idea of how long the navigation takes, and when one is in progress, is important. Single-page app navs has been crippled so far by being just a single instant in time (whenever It also appears to be important for accessibility technology; see some discussions in w3c/aria#1353. |
I'm sorry to bother you, but even after reading these I don't see a need for asynchronous execution. Perhaps I'm having a blind spot, but from the proposal doc's I don't even see a requirement for the I.e., instead: appHistory.addEventListener("navigate", e => {
// Don't intercept cross-origin navigations; let the browser handle those normally.
if (!e.sameOrigin) {
return;
}
// Don't intercept scroll-to-fragment or scroll-to-text-fragment navigations.
if (e.fragmentTarget) {
return;
}
if (e.formData) {
e.respondWith(processFormDataAndUpdateUI(e.formData));
} else {
e.respondWith(doSinglePageAppNav(e.destinationEntry));
}
}); ... write ... appHistory.addEventListener("navigate", e => {
// Don't intercept cross-origin navigations; let the browser handle those normally.
if (!e.sameOrigin) {
return;
}
// Don't intercept scroll-to-fragment or scroll-to-text-fragment navigations.
if (e.fragmentTarget) {
return;
}
if (e.formData) {
processFormDataAndUpdateUI(e.formData);
} else {
doSinglePageAppNav(e.destinationEntry);
}
}); I guess that would perform the same purpose. |
Ah! What you may be missing is that
By passing the promise to Without passing those promises to |
I'll close this since I think we've had a good discussion here that's mostly concluded (?), and I'm looking to move issues to the new repo, but please feel free to open a new issue over there if you think this is still unclear. Also, note that the pending navigations feature is receiving some good scrutiny from @esprehn and definitely needs some work: see WICG/navigation-api#10, WICG/navigation-api#11, and WICG/navigation-api#13. |
Sure, please go ahead. Thank you for for massive efforts in this! I still have a feeling that asynchronous overhead is not required here, particularly since |
At https://github.com/slightlyoff/history_api/blob/master/app_history.md#navigations-while-a-navigation-is-ongoing it reads:
Does it make sense to have navigation be asynchronous if it's serialized in the end anyway?
Wouldn't it be sufficient to have the implementor of the event handler decide on his/her own whether to utilize promises from within the handler by creating/awaiting promises locally?
The text was updated successfully, but these errors were encountered: