编辑了一些错误类型的
我所做的
// in component
export class WhatIdidComponent implements OnInit {
storeData$
combine$;
constructor(
private store: Store<AppState>
private route: ActivatedRoute,
) {
this.storeData$ = this.store.pipe(select((state: AppState) => state['p']['reviews']), share());
this.combine$ = combineLatest(
//I inserted async storeData$ variable in combineLatest
this.storeData$,
this.route.params.pipe(/*any operator*/)
)
}
}//d
//in template.html
<ng-container *ngIf="(storeData$ | async) as data; else loading">
// not working properly when this.storeData$ is in combineLatest
{{data.blah}}
</ng-container>当我在this.storeData中插入combineLatest时,storeData$ with异步管道无法工作
我认为this.storeData$与combineLatest无关。因为this.storeData$是this.storeData$。
但它似乎与combineLatest有关。为什么?以及如何解决这个问题?
我想要的是
感谢您的阅读
发布于 2018-12-05 09:23:39
您正在创建一个具有share的多播主题,一旦订阅可观察到的combineLatest,该主题将订阅您的源(this.store)。这导致所谓的“延迟订阅者”错过了原始可观察到的通知。本例中的晚订户都是其他订户,除了第一个订户,因此您的异步管道也是。
您的选择是要么放下share管道来保持寒冷的可观察性,要么使用例如shareReplay(1)来创建缓存行为。
https://stackoverflow.com/questions/53628654
复制相似问题