![](/img/trans.png)
[英]Rxjs - How to call two httpService after combinelatest?
[英]rxjs call combineLatest in combineLatest
我遇到了rxjs
和combineLatest
方法的問題。 我想打電話給combineLatest
在combineLatest
和它不工作,雖然它返回可觀察對象。 請幫忙解決問題。 從不調用console.log
實際上,所有觀察者都在不同的文件中,所以我無法將this.search$
移到this.services$
this.search$ = store.select('search');
this.services$ = Observable.combineLatest(
store.select('currentRegions'),
store.select('services'),
(regions, services) => {
// some filter here
return services;
}
);
this.autocomplete$ = Observable.combineLatest(
this.search$,
this.services$,
(search, services) => {
console.log('show me, please');
return '';
}
);
已解決:沒有任何訂閱者它不起作用,所以我不得不訂閱它
combineLatest()
運算符在其所有源Observable發出至少一個值時發出一個值。
因此,如果console.log(...)
從不打印它意味着this.search$
或this.services$
永遠不會發出任何內容。 換句話說,這意味着store.select('currentRegions')
, store.select('services')
或store.select('search')
永遠不會發出任何值。
請注意,您可以使用startWith()
(即使使用startWith(null)
)。
RxJS CombineLatest是一種AngularJS $ q.all
import 'rxjs/add/observable/combineLatest';
Observable
.combineLatest(this.store.select('currentRegions'), this.store.select('services')
.do(console.log)
.subscribe();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.