Javatpoint Logo
Javatpoint Logo

RxJS isEmpty() Conditional Operator

RxJS isEmpty() operator is a conditional operator that returns an output as false if the input observable emits any values or returns an output as true if the input observable completes without emitting any values.

In other words, we can say that the RxJS isEmpty() operator is used to tell whether any values are emitted by an observable or not.

Syntax:

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

Or

Parameter Explanation

There are no parameters to explain.

Return value

The RxJS isEmpty() operator returns an observable with a Boolean value indicating whether the observable was empty or not. It returns an output as true if the source observable is empty; otherwise, false.

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

Example 1 (Emit true for an empty Observable)

Output:

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

RxJS isEmpty() Conditional Operator

In the above example, you can see that it has shown the output as true because the source observable is empty and that' why the output given by observable is true.

Example 2 (Emit false for a non-empty Observable)

Output:

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

RxJS isEmpty() Conditional Operator

In this example, you can see that when the source observable is not empty and you have put values within that, it has shown the output as false.


Next TopicRxJS Operators





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA