【发布时间】:2018-10-15 23:44:21
【问题描述】:
我正在尝试将 ionic 的加载控制器与 Firestore 查询一起使用。据我所知,这会返回一个 observable 并且还会监听查询值的变化。
但是有没有办法在函数中知道 observable 的值是否已经改变?因为现在加载程序会在每次点击时显示,即使没有任何更改,我希望加载程序仅在查询结果发生更改时显示。
这就是我想做的事
category(category){
let loading = this.load.create({
content: 'Please wait...'
});
this.selected = category;
this.fsp.getCategory(category).subscribe(res => {
if(res has changed){
loading.present();
this.data = this.group.groupEvents(res);
loading.dismiss();
} else(observable value remained the same) {
this.data = this.group.groupEvents(res);
}
});
}
【问题讨论】:
标签: typescript ionic-framework observable