Javatpoint Logo
Javatpoint Logo

RxJS every() Conditional Operator

RxJS every() operator is a conditional operator used to return an observable that emits whether every item of the source observable satisfies the condition specified.

In other words, we can say that in the RxJS every() operator, if all values pass predicate before completion, it emits true, else false.

Syntax:

Following is the syntax of the RxJS every() conditional operator:

Or

Parameter Explanation

  • predicate_func: It specifies the input given to this operator. It takes the source item and checks if it satisfies the given condition.
  • predicate: It is the same as predicate_func and specifies a function to determine if an item meets a specified condition or not.
  • thisArg: This is used in the callback. This is an optional argument. Its default value is undefined.

Return value

The RxJS every() operator returns an observable of booleans according to the input function satisfies the condition on each of the value on source observable.

Let us see some examples of the RxJS every() operator to understand it clearly.

Example 1 (Emit true or false by comparing the values)

Output:

After executing the above example, you will see the following result:

RxJS every() Conditional Operator

Example 2

Output:

After executing the above example, you will see the following result:

RxJS every() Conditional Operator

Example 3 (When some values are false)

Output:

After executing the above example, you will see the following result:

RxJS every() Conditional Operator

Example 4 (When all values are true)

Output:

After executing the above example, you will see the following result:

RxJS every() Conditional Operator
Next TopicRxJS Operators




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA