Sometimes, we want to return an empty Observable with Rxjs.
In this article, we’ll look at how to return an empty Observable with Rxjs.
How to return an empty Observable with Rxjs?
To return an empty Observable with Rxjs, we can use EMPTY
or of
.
For instance, we write
import { EMPTY, empty, of } from "rxjs";
EMPTY;
of({});
to import EMPTY
which is an empty observable.
We can also call of
with an empty object to return an empty observable.
Conclusion
To return an empty Observable with Rxjs, we can use EMPTY
or of
.