【发布时间】:2019-01-24 14:01:36
【问题描述】:
我使用shareReplay 调用一次(如缓存)一个网络服务来检索一些信息:
为我服务:
getProfile(): Observable<Customer> {
return this.callWS().pipe(shareReplay(1));
}
在多个组件中:
this.myService.getProfile().subscribe(customer => {
console.log('customer informations has been retrieved from WS :', customer);
});
现在我想添加一个方法来强制刷新信息(仅绕过一次 shareReplay)。我尝试将我的 observable 存储在一个变量中,并在重新初始化之前将其设置为 null,但它似乎破坏了组件订阅..
有什么帮助吗?
谢谢
【问题讨论】:
-
我会使用状态存储(ngrx,ngxs)
-
我也有同样的问题..任何更新编辑你的问题..谢谢
标签: typescript asynchronous caching rxjs reactive-programming