当有数据时,AngularFire2 / firestore valueChanges()返回null

Joe*_*Ker 5 angularfire2 google-cloud-firestore

I'm trying to get a document out of a firestore collection on load of a angularfire2 application. When loading the application in incognito mode the function returns null on first load, but after a refresh it returns the data I'm expecting.

public GetConfig(): Observable<Config> {
return this.documentDB
  .collection("Configs")
  .valueChanges()
  .do(c => {
    this.SetCurrentVersion((c[0] as Config).currentversion);
  })
  .map(c => c[0] as Config);
Run Code Online (Sandbox Code Playgroud)

}

Has anyone else run into issues like this? I have verified that the Configs collection has documents available to be returned. My angularfire2 version is 5.0.0-rc.4.

I've also tried using snapshotChanges and getting the specific document from the collection, all are null on first load and work on refresh.

Joe*_*Ker 1

如果它没有返回我们的数据,我们最终会抛出一个错误,然后重试。

return this.documentDB
    .collection("Configs")
    .valueChanges()
    .do(c => {
      if (c.length > 0 && c != null) {
        this.config = c[0] as Config;
        this.SetCurrentVersion(this.config.currentversion);
      }
    })
    .map(c => {
      if (c.length === 0) {
        throw new Error("could not get config");
      } else {
        return c[0] as Config;
      }}).retry(5);
Run Code Online (Sandbox Code Playgroud)