更新可观察的结果

时间:2019-06-21 05:51:27

标签: angular typescript ionic-framework rxjs observable

我的 tabs.ts

下有一个观测对象
ngOnInit() {
  this.cartService.getCart(this.authId).subscribe(cart => {
    this.cart = cart;
  });
}

文件 cart.service.ts

下的cartService.getCart
getCart(authId: string): Observable<Cart> {
  this.cartsCollection2 = this.afs.collection('carts', ref => ref.where('authId', '==', authId).where('status', '==', 'active'));
  this.cart = this.cartsCollection2.snapshotChanges().pipe(
    map(changes => {
      return changes.map(action => {
        const data = action.payload.doc.data() as Cart;
        data.id = action.payload.doc.id;
        return data;
      });
    })
  );
  return this.cart;
}

付款后,我将购物车状态更新为“已付款”,而不是“有效”,这会更新可观察结果。本质上,我的tabs.ts中的购物车现在应该为空。如何获取结果?

0 个答案:

没有答案