RxJS - Conditional Operator find



This will return the observable when the first value of the source Observable satisfies the condition for the predicate function taken as input.

Syntax

find(predicate_func: function): Observable

Parameters

predicate_func − The input given to this operator is a predicate_func that will take in the source item and checks if it satisfies the condition given.

Return value

It will return the observable when the first value of the source Observable satisfies the condition for the predicate function taken as input.

Example

import { of } from 'rxjs';
import { find } from 'rxjs/operators';

let list1 = of(24, 3, 4, 9, 10, 15);
let final_val = list1.pipe(find(x => x % 2 === 0),);
final_val.subscribe(x ==> console.log(x));

Output

24
Advertisements