-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Navigation pipeline should support cancelation #217
Comments
There is no notion of "cancellation" in promises at this point in time, though I have heard talk that the API may be improved to include that at some point in the future. But, as things are, there's nothing that Aurelia can really do to handle this automatically. My recommendation would be, for this case, to not return a promise from your activate method. Instead, fix up the view for that screen so that it shows its own internal loading indicator until the data is loaded. That way the router is free to navigate away even if the data hasn't completed loading. |
Is there a way that Aurelia that if given a promise can wrap that promise in another container which can allow for an early reject. So let's say PromiseWrapper would take a promise and have a method called EarlyReject which would reject the promise mid way. |
I'm going to leave this open because I think we do need to handle cancelation at some point, and we don't have an issue tracking it yet. |
While not part of promises bluebird has cancellation http://bluebirdjs.com/docs/api/cancellation.html |
Thou shalt not force the user to wait 15 seconds for activate to finish. I'd close this |
Let's keep it for now, though I don't think we'd do it outside of overhauling the router in some future version. |
With regards to overhauling the router in a future version, I'm adding a reference to a somewhat related issue. It's about rendering a parent route's viewmodel before a child route's |
Might I add that whole middleware pipeline as in asp.net core and koa looks so appealing |
I'm honestly with Alex here. If you want to support cancellation, you can easily do this by wrapping a promise. activate() {
return new Promise((resolve, reject) => {
this.doMyReallyLongTimeThing().then(resolve);
setTimeout(reject, 15000);
}
} @EisenbergEffect I'd vote to close. Your thoughts? |
I'll close. I believe that this is the recommended way to handle cancellation of promises actually. |
one of my viewmodels activate function takes a while to complete around 15 seconds, if the route is mid activation and then I click another route, the router will wait for the old one to finish activating before proceeding to the new one which means that you're essentially stuck for those 15 seconds. Is there a way for it to cancel the old activation and proceed to the new one.
The text was updated successfully, but these errors were encountered: