如何在angularfire中完成pipe()后调用函数
我有一个非常简单的问题,但它让我沮丧了好几个小时 我有一个来自angular firebase的可观察快照,我正在通过map函数来改变一些数据 像这样:如何在angularfire中完成pipe()后调用函数,angular,asynchronous,pipe,angularfire,Angular,Asynchronous,Pipe,Angularfire,我有一个非常简单的问题,但它让我沮丧了好几个小时 我有一个来自angular firebase的可观察快照,我正在通过map函数来改变一些数据 像这样: this.itemsList = this.itemsRefList.snapshotChanges().pipe( map(changes => changes.map(c => ({ product: c.payload.key, firmware: c.payload.child('late
this.itemsList = this.itemsRefList.snapshotChanges().pipe(
map(changes =>
changes.map(c => ({
product: c.payload.key,
firmware: c.payload.child('latest').val(),
ref: c.payload.ref,
})
)
)
);
管道完成后,我想简单地调用一个函数,我如何实现这一点
具体地说,我使用的是ngx管理,并且有一张内容默认为加载微调器的卡
<nb-card>
<nb-card-header>
...
</nb-card-header>
<nb-card-body [nbSpinner]="tableDataLoading" nbSpinnerSize="giant" nbSpinnerStatus="warning">
<div *ngIf="itemsList | async as items">
<ng2-smart-table [settings]="settings" [source]="items"></ng2-smart-table>
</div>
</nb-card-body>
</nb-card>
...
一旦填充了itemList,我想调用一个函数,将tableDataLoading设置为false,这样微调器就会消失
正确的方法是什么?我已经尝试了很多方法,包括订阅itemsList,尝试调用该函数(告诉我它不是函数),尝试查看是否可以以某种方式更改html模板中的变量,但没有效果,等等在changes.map函数中添加括号
this.itemsList = this.itemsRefList.snapshotChanges().pipe(
map(changes =>{
let temp = changes.map(c => ({
product: c.payload.key,
firmware: c.payload.child('latest').val(),
ref: c.payload.ref,
}))
//map is done, call other code here
this.callOtherMethodHere();
return temp;
})
);
只需在映射后添加一个.tap。如果我尝试此操作,编译器会抱怨类型“Observable”不可分配给类型“Observable”。类型“void”不可分配给类型“any[]”。太好了,谢谢您的帮助,我只需删除倒数第二个;返回温度;});