0
좋아, 그래서이 예제에 설명 된대로 중포 기지로 Geofire 설정에 대한 예를 다음 해요 : https://github.com/firebase/geofire-js/blob/master/examples/html5Geolocation/js/html5Geolocation.js자바 스크립트 Geofire + 중포 기지는 응용 프로그램을 반응 - 클래스 기반의 로직 인스턴스 생성/선언에 inconsitencies이
것은 내가이 (가)에서 다음과 같은 경우 일반 JS 코드 파일은 geoFire 변수를 잘 설정됩니다
import * as firebase from 'firebase';
import GeoFire from 'geofire';
const config = {
// config stuff here
};
firebase.initializeApp(config);
let geoLocationRef = firebase.database().ref('users-geolocation').push();
let geoFire = new GeoFire(geoLocationRef);
console.log('GEOFIRE :::::: ', geoFire);
// output: GEOFIRE :::::: GeoFire {ref: ƒ, set: ƒ, get: ƒ, remove: ƒ, query: ƒ}
그러나, 나는이 GeoFireUtil.js 클래스에서 비슷한 일을하려고하면 나는 내가 얻고 싶은 이제까지 GeoFire 기능이 포함되어보다 쉽게 할 수 있도록 'geoFire is undefined':
import firebase from './firebase-connection';
import GeoFire from 'geofire';
// geofire connection ##################
//let geoLocationRef = firebase.database().ref('users-geolocation').push();
// Create a new GeoFire key under users Firebase location
//let geoFire = new GeoFire(geoLocationRef.child('geofire'));
class GeoFireUtil {
constructor(userId, username) {
this.userId = userId;
this.username = username;
this.geoLocationRef = firebase.database().ref('users-geolocation').push();
this.geoFire = new GeoFire(this.geoLocationRef);
console.log('CLASS GEOFIRE ::::: ', this.geofire);
// output: CLASS GEOFIRE ::::: undefined
}
....
}
아직 JS를 마스터하지 못했지만 일부 개념은 여전히 나를 벗어났습니다 ... 누군가가 올바른 방향으로 나를 가리킬 수 있습니까?