Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular Rxjs 6管道不在代码中工作_Angular_Rxjs_Google Cloud Firestore - Fatal编程技术网

Angular Rxjs 6管道不在代码中工作

Angular Rxjs 6管道不在代码中工作,angular,rxjs,google-cloud-firestore,Angular,Rxjs,Google Cloud Firestore,我使用的代码来自连接到Firestore的Rxjs版本代码库,我更改了所有内容以使用正确的导入并添加了.pipe(map)。我听到一句话:“DocumentChangeAction[]类型上不存在[ts]属性'pipe'。下面是我的函数,它给了我这个问题。多谢各位 private mapAndUpdate(col: AngularFirestoreCollection<any>) { var values; if (this._done.value || t

我使用的代码来自连接到Firestore的Rxjs版本代码库,我更改了所有内容以使用正确的导入并添加了.pipe(map)。我听到一句话:“DocumentChangeAction[]类型上不存在[ts]属性'pipe'。下面是我的函数,它给了我这个问题。多谢各位

  private mapAndUpdate(col: AngularFirestoreCollection<any>) {       
  var values;


if (this._done.value || this._loading.value) { return };

this._loading.next(true)

// Map snapshot with doc ref (needed for cursor)
return col.snapshotChanges()
  .pipe(tap(arr => {
    values = arr.pipe(
      map((snap: any) => {
      const data = snap.payload.doc.data();
      const doc = snap.payload.doc;
      return { ...data, doc }; 
    }))
  ));

    // If prepending, reverse array
    values = this.query.prepend ? values.reverse() : values

    // update source with new values, done loading
    this._data.next(values)
    this._loading.next(false)

    // no more values, mark done
    if (!values.length) {
      this._done.next(true)
    }
})
.take(1)
.subscribe()}
私有映射和更新(列:AngularFirestoreCollection){
var值;
if(this._done.value | this._load.value){return};
此.\u正在加载。下一个(真)
//带有doc ref的映射快照(光标需要)
返回列快照更改()
.管道(分接头(arr=>{
值=arr.pipe(
映射((捕捉:任意)=>{
const data=snap.payload.doc.data();
const doc=snap.payload.doc;
返回{…数据,doc};
}))
));
//如果是前置,则反转数组
values=this.query.prepend?values.reverse():值
//使用新值更新源,完成加载
此._data.next(值)
此.\u正在加载。下一个(false)
//没有更多值,标记完成
如果(!values.length){
这个。_完成。下一个(正确)
}
})
.采取(1)
.subscribe()}

您导入了这些吗

import { Observable, of } from 'rxjs';
import { map, scan, take, switchMap, startWith, tap, filter } from 'rxjs/operators';

这些是进口的吗

import { Observable, of } from 'rxjs';
import { map, scan, take, switchMap, startWith, tap, filter } from 'rxjs/operators';

问题在
点击
操作员:

tap(arr=>{
值=arr.pipe(
映射((捕捉:任意)=>{
const data=snap.payload.doc.data();
const doc=snap.payload.doc;
返回{…数据,doc};
}))
));
arr
是一个
DocumentChangeAction
数组,不可观察。您必须映射每个项目。结果已经计算出来,因此无需再次处理可观察项

tap(arr=>{
值=arr.map((捕捉:任意)=>{
const data=snap.payload.doc.data();
const doc=snap.payload.doc;
返回{…数据,doc};
});
...

问题在
点击
操作员:

tap(arr=>{
值=arr.pipe(
映射((捕捉:任意)=>{
const data=snap.payload.doc.data();
const doc=snap.payload.doc;
返回{…数据,doc};
}))
));
arr
是一个
DocumentChangeAction
数组,不可观察。您必须映射每个项目。结果已经计算出来,因此无需再次处理可观察项

tap(arr=>{
值=arr.map((捕捉:任意)=>{
const data=snap.payload.doc.data();
const doc=snap.payload.doc;
返回{…数据,doc};
});
...

是的,我有。视觉代码甚至无法识别代码正在使用“take”,因为我相信,这是一个错误。角度版本是什么角度版本角度版本是6.0.8我看不到任何问题。视觉代码甚至无法识别“take”代码正在使用,因为,我相信,这个错误。角度版本是什么角度版本是6.0.8我看不出任何问题