RxJS isEmpty() Conditional OperatorRxJS 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 ExplanationThere are no parameters to explain. Return valueThe 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: 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: 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
|