【问题标题】:ERROR TypeError: Observable_1.Observable.combineLatest is not a function错误类型错误:Observable_1.Observable.combineLatest 不是函数
【发布时间】:2018-07-01 16:56:26
【问题描述】:

我正在使用 Angular 5.2 和 Rxjs 5.6-forward-compat.3。

我正在尝试合并两个 Firestore 集合,我认为问题与导入有关,但我尝试了所有可能的组合和选项,所以我不确定。

Here is the code:`IMPORTS: 
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/combineLatest';

Here is my observable:
getActiveMedicationandCompliance(start: any): Observable<any[]> {
    const email = this.authService.getLoginUserid();
    const userDoc = this.afs.doc<User>(`users/${email}`);

    return userDoc
      .collection<any>(collection.MY_MEDICATION_CABINET, ref =>
        ref.where('active', '==', true).orderBy('medicationName', 'asc')
      )
      .snapshotChanges()
      .map(changes => {
        return changes.map(action => {
          let data = action.payload.doc.data();
          data.id = action.payload.doc.id;
          return userDoc
            .collection<any>(collection.MY_MEDICATION_COMPLIANCE, ref =>
              ref
                .where('medicationCabinetId', '==', data.id)
                .where('createdDate', '>=', start)
                .orderBy('createdDate', 'asc')
            )
            .snapshotChanges()
            .map(changes => {
              changes.map(action => {
                const dataCompliance = action.payload.doc.data();
                dataCompliance.id = action.payload.doc.id;
                return (data = Object.assign(
                  {},
                  { ...dataCompliance, ...data }
                ));
              });
            });
        });
      })
      .mergeMap(observables => Observable.combineLatest(observables));
  }
`

【问题讨论】:

    标签: angular observable google-cloud-firestore


    【解决方案1】:

    combineLatest 不是运算符,而是可观察导入的一部分:

    import 'rxjs/observable/combineLatest';
    

    【讨论】:

    • 好建议,但是...已经尝试过,也尝试过 import { combineLatest } from 'rxjs/observable/combineLatest';.
    • 不,一样。我什至尝试了另一个版本的可观察对象,只是为了尝试而更改了值而不是快照,但那里也没有任何更改。会不会是我的 rxjs 版本?我不会降级,因为我打算很快升级到 A V6。
    • 这个问题可以在 stackblitz 中重现吗?
    • 请不要担心...但是您在我的代码中发现任何问题吗?我相信我所做的一切都是正确的,实际上自从我使用 FS 以来,我认为我的(愚蠢的)wa 只是为了复制数据,即使我讨厌它......
    • 我没有发现任何问题,我最好的猜测是与构建系统相关的问题,我的建议是升级 rxjs。
    猜你喜欢
    • 1970-01-01
    • 2023-03-22
    • 2016-03-27
    • 2018-04-28
    • 2019-02-14
    • 2021-10-02
    • 2021-10-30
    • 2018-11-22
    • 2017-10-12
    相关资源
    最近更新 更多