every

function stable

Returns an Observable that emits whether or not every item of the source satisfies the condition specified.

every<T>(predicate: (value: T, index: number, source: Observable<T>) => boolean, thisArg?: any): OperatorFunction<T, boolean>

Parameters

predicate

A function for determining if an item meets a specified condition.

thisArg

Optional. Default is undefined.

Optional object to use for this in the callback.

Returns

OperatorFunction<T, boolean>: A function that returns an Observable of booleans that determines if all items of the source Observable meet the condition specified.

Description

If all values pass predicate before the source completes, emits true before completion, otherwise emit false, then complete.

every marble diagram

Example

A simple example emitting true if all elements are less than 5, false otherwise

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

 of(1, 2, 3, 4, 5, 6).pipe(
    every(x => x < 5),
)
.subscribe(x => console.log(x)); // -> false

Overloads

every(predicate: BooleanConstructor): OperatorFunction<T, Exclude<T, Falsy> extends never ? false : boolean>

Parameters

predicate

Type: BooleanConstructor.

Returns

OperatorFunction<T, Exclude<T, Falsy> extends never ? false : boolean>

every(predicate: BooleanConstructor, thisArg: any): OperatorFunction<T, Exclude<T, Falsy> extends never ? false : boolean>

Deprecation Notes

Use a closure instead of a thisArg. Signatures accepting a thisArg will be removed in v8.

Parameters

predicate

Type: BooleanConstructor.

thisArg

Type: any.

Returns

OperatorFunction<T, Exclude<T, Falsy> extends never ? false : boolean>

every(predicate: (this: A, value: T, index: number, source: Observable<T>) => boolean, thisArg: A): OperatorFunction<T, boolean>

Deprecation Notes

Use a closure instead of a thisArg. Signatures accepting a thisArg will be removed in v8.

Parameters

predicate

Type: (this: A, value: T, index: number, source: Observable) => boolean.

thisArg

Type: A.

Returns

OperatorFunction<T, boolean>

every(predicate: (value: T, index: number, source: Observable<T>) => boolean): OperatorFunction<T, boolean>

Parameters

predicate

Type: (value: T, index: number, source: Observable) => boolean.

Returns

OperatorFunction<T, boolean>

© 2015–2021 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.
Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
https://rxjs.dev/api/operators/every