RxJS - Conditional Operator isEmpty



This operator will give the output as true if the input observable goes for complete callback without emitting any values and false if the input observable emits any values.

Syntax

isEmpty(): Observable

Return value

It will return an observable with a boolean value as true if the source observable is empty otherwise false.

Example

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

let list1 = of();
let final_val = list1.pipe(isEmpty(),);
final_val.subscribe(x => console.log(x));

Since the source observable is empty, the output given by observable is true.

Output

true
Advertisements