0
votes

I have an observable of array of items and an observable of item. I want subscribe to both and get the index of observable of item from observable of array of items

i already tried switchmap, concatmap and mergemap but didn't get any result

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
1

1 Answers

2
votes
import { combineLatest } from 'rxjs';
import { map } from 'rxjs/operators';

...

combineLatest(
  selectedcategory$,
  allcategories$,
).pipe(
  map(([selected, categories]) => categories.findIndex(/* whatever logic you need */),
).subscribe(...);