RxJS - Conditional Operator every


It will return an Observable based on the input function satisfies the condition on each of the value on source Observable.

Syntax

every(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 returns an Observable based on the input function satisfies the condition on each of the value on source Observable.

Example

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

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

Output

false
Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements