gpt4 book ai didi

javascript - 如何将 Observable 转换为 FirebaseObjectObservable

转载 作者:行者123 更新时间:2023-11-30 00:01:58 25 4
gpt4 key购买 nike

代码:

(转换不适用于这两种方法)

1. this.af.database.object('/users/'+key)
.do((something:any)=>console.log(something)) as FirebaseObjectObservable<any>;
2. ..switchMap(()=>this.af.database.object('/users/'+key)) as FirebaseObjectObservable<any>;

问题:

  1. 有什么问题?
  2. 我能否在不丢失任何数据的情况下随处将“any”替换为“User”类型?

最佳答案

好的解决了:

1. <FirebaseObjectObservable<any>>this.af.database.object('/users/'+key)
.do((something:any)=>console.log(something));
2. <FirebaseObjectObservable<any>>..switchMap(()=>this.af.database.object('/users/'+key));

为了替换 any,我在我的用户类中添加了一个 $key 属性,所以现在我可以这样做:

1. <FirebaseObjectObservable<User>>this.af.database.object('/users/'+key)
.do((something:any)=>console.log(something));
2. <FirebaseObjectObservable<User>>..switchMap(()=>this.af.database.object('/users/'+key));

关于javascript - 如何将 Observable 转换为 FirebaseObjectObservable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40110518/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com