- RxJS Tutorial
- RxJS - Home
- RxJS - Overview
- RxJS - Environment Setup
- RxJS - Latest Updates
- RxJS - Observables
- RxJS - Operators
- RxJS - Working with Subscription
- RxJS - Working with Subjects
- RxJS - Working with Scheduler
- RxJS - Working with RxJS & Angular
- RxJS - Working with RxJS & ReactJS
- RxJS Useful Resources
- RxJS - Quick Guide
- RxJS - Useful Resources
- RxJS - Discussion
RxJS - Conditional Operator findIndex
This operator will give you the index of the first value from source Observable which happens to satisfy the condition inside the predicate function.
Syntax
findIndex(predicate_func: function): Observable
Parameters
predicate_func The predicate_function will be deciding the first index to be picked when the condition satisfies.
Return value
It will return an observable with the first value from source Observable which happens to satisfy the condition inside the predicate function
Example
import { of } from 'rxjs'; import { findIndex } from 'rxjs/operators'; let list1 = of(24, 3, 4, 9, 10, 15); let final_val = list1.pipe(findIndex(x => x % 2 === 0),); final_val.subscribe(x => console.log(x));
Output
0
Advertisements