-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
NavGuards with async HTTP Calls does not work v3 and probably also v2 #11090
Comments
Hello, thanks for using Ionic! We will look into this. |
@mburger81 What happens if you change it to the following: ionViewCanEnter(): Promise<any> {
return this.userService.current().toPromise();
} |
@zbarbuto It works but there is also a BUG on it
|
Hello! Thanks for opening an issue with us! As this seems like more of a support question related to using observables, I will urge that you ask this question on our forum (forum.ionicframework.com) or on our [slack channel](https://ionic-worldwide.slack.com/messages?]. Thanks for using Ionic! |
Comm on guys! This is not a support request. This was definitly a bug you closed some release ago with version 3.0.1. We don't know if it was a side effect or something else. |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Ionic version: (check one with "x")
[ ] 1.x
[x] 2.x
[3] 2.x
I'm submitting a ... (check one with "x")
[x] bug report
[x] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/
Current behavior:
We are trying to handle a NavGuard calling a HTTP request by an Obersvable. We have an get for current/user in an service, something like that:
for our lazy loading page on ionic3 we will check if user is authenticated on ionViewCanEnter, so this has to be async.
We are doing this:
The http call is never started, so it looks like there is now subscription to observable. It's difficult to debug, but I think it could be a problem by combine
Observables
with promises.Also the commented code with
toPromise()
for observable does not work.Expected behavior:
The thing is, it would be nice if we can call in NavGuards directly some httpCalls, but this for now we can not do. I don't know if this is a bug of Promise/Observable or Ionic.
Other information:
Ionic info: (run
ionic info
from a terminal/cmd prompt and paste output below):The text was updated successfully, but these errors were encountered: