geofire-js: Angular 6 - Error while creating an instance of GeoFire
Version info
Firebase: ^4.12.1 GeoFire: ^4.1.2
Other (e.g. Node, browser, operating system) (if applicable): “agm/core”: “^1.0.0-beta.2”, “angular/animations”: “^6.0.0”, “angular/cdk”: “^6.0.0”, “angular/common”: “^6.0.0”, “angular/compiler”: “^6.0.0”, “angular/core”: “^6.0.0”, “angular/forms”: “^6.0.0”, “angular/http”: “^6.0.0”, “angular/material”: “^6.0.0”, “angular/platform-browser”: “^6.0.0”, “angular/platform-browser-dynamic”: “^6.0.0”, “angular/router”: “^6.0.0”, “fortawesome/fontawesome”: “^1.1.7”, “ng-select/ng-select”: “^1.4.0”, “ngrx/effects”: “^5.2.0”, “ngrx/store”: “^5.2.0”, “angularfire2”: “^5.0.0-rc.6.0”, “bootstrap”: “^4.1.0”, “cordova-android”: “^7.1.0”, “cordova-plugin-device”: “^2.0.2”, “cordova-plugin-geolocation”: “~4.0.1”, “core-js”: “^2.5.5”, “firebase”: “^4.12.1”, “font-awesome”: “^4.7.0”, “geofire”: “^4.1.2”, “hammerjs”: “^2.0.8”, “mt-latlon”: “^0.1.1”, “rxjs”: “>=5.6.0-forward-compat.4”, “rxjs-compat”: “^6.1.0”, “uuid”: “^3.2.1”, “web-animations-js”: “^2.3.1”, “zone.js”: “0.8.26”
Test case
Steps to reproduce
import { Injectable, NgZone } from ‘@angular/core’; import { AngularFireDatabase } from ‘angularfire2/database’; import { GoogleMapsAPIWrapper } from ‘@agm/core’; import { MapsAPILoader } from ‘@agm/core’; import * as GeoFire from ‘geofire’;
@Injectable() export class GeoService extends GoogleMapsAPIWrapper { dbRef: any; geoFire: any;
constructor(private db: AngularFireDatabase, private auth: AuthService) { const path = this.getDBRef(this.vehicleType); this.dbRef = this.db.list(path); this.geoFire = new GeoFire(this.dbRef.$ref); }
getDBRef = (type) => {
const country = (this.auth.userInfo.country ? this.auth.userInfo.country : ‘India’);
const returnDBRef = ${country}/${type.toLowerCase()}
;
return returnDBRef;
};
}
Expected behavior
The geoFire instance should be created
Actual behavior
Runtime error while creating the following: this.geoFire = new GeoFire(this.dbRef.$ref);
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 33 (12 by maintainers)
The codebase for
geofire
has been updated to resolve this issue however a new build has not been deployed to npm. You could install straight from GitHub though withnpm i firebase/geofire-js
.This works in firebase functions with node 8:
@money2623 as it structured modularly you’ll need to either import it as:
@ravivit9 ooh, I can’t really say. Quality code is obviously very important to them, so the PR will have to be ripped apart and judged. But if you reach out to me via email (my email is on my profile), I can help you out until an official fix is merged in.
Man…I swear I did this and I still got the error, but now it seems to work! Appreciate looking into this! @MichaelSolati
@CossyCossy there is a small chance in how important would take place. Instead of
import * as geofire from 'geofire'
your import would/should look likeimport { Geofire } from 'geofire'
.I have the same issue with “firebase”: “^5.1.0” and “geofire”: “^4.1.2” in the following line: this.geoFire = new GeoFire(this.dbRef.query.ref);
Any update on how to move forward with GeoFire and Angular 6 Thanks!
@ccynn update line 7 of your
index.js
to:@jaufang do you have a sample repo? (I don’t mind helping!)
any update?