TheSegfault
12/11/2017 - 12:42 PM

Monkey Patch Observable + Error throw

Ionic librabry not returning error properly

    private isError(data: PositionError | Geoposition): data is PositionError {
        return ((data as PositionError).code !== undefined);
    }

    private $watchPosition(options: GeolocationOptions): Observable<Geoposition> {
        return this.geolocation.watchPosition(options)
            .do((position) => {
                if (this.isError(position)) {
                    throw new PositionError();
                }
            });
    }