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

Geolocation watchPosition errors #2146

Closed
Jahrenski opened this issue Nov 24, 2017 · 0 comments
Closed

Geolocation watchPosition errors #2146

Jahrenski opened this issue Nov 24, 2017 · 0 comments

Comments

@Jahrenski
Copy link

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/

Current behavior:
It is currently impossible to handle PositionErrors occuring in the success path of the watchPosition observable. The only thing you can do is ignore them.

Expected behavior:
I expect errors to use the error path of the subscriber OR that we use a union type of Geoposition|PositionError

Related code:

this.geolocation.watchPosition({ enableHighAccuracy:false, timeout:10000, maximumAge:10000 }).subscribe( pos => { 
  
  if( ( pos as Geoposition ).coords ) {
    console.log( pos );
  } else {
    var positionError = (pos as PositionError); //Compiling error : Type 'Geoposition' cannot be converted to type 'PositionError'. Property 'code' is missing in type 'Geoposition'.
    console.log( positionError );
  }
}, positionError => {
  console.log( positionError );
});

Other information:
Also the documentation is outdated. You can't unsubscribe from watchPosition as observables don't have the unsubscribe method anymore. You need to use takeUntil().

"@angular/common": "^5.0.1",
"@ionic-native/core": "^4.4.0",
"@ionic-native/geolocation": "^4.4.2"

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

No branches or pull requests

2 participants