我有一个可观察的物品阵列和一个可观察的物品。我想同时订阅两者,并从可观察项数组中获得可观察项的索引
我已经尝试过switchmap,concatmap和mergemap,但没有得到任何结果
selectedcategory$ = this.store.pipe(select(selectSelectedCategory));
```observable of array of items
allcategories$ = this.store.pipe(select(selectCategories));
```i am working with ngrx
I an expecting index of item
答案 0 :(得分:2)
import { combineLatest } from 'rxjs';
import { map } from 'rxjs/operators';
...
combineLatest(
selectedcategory$,
allcategories$,
).pipe(
map(([selected, categories]) => categories.findIndex(/* whatever logic you need */),
).subscribe(...);