Can I convert a boolean or a primitive into an observable?

Viewed 5769

I have a javascript function which returns an boolean in some cases or an Observable in some other cases. Can I somehow always return an Observable by creating Observable out of a boolean?

2 Answers

Addition to the accepted answer, the return of(data) (and not Observable.of(data)) is enough for RxJS 6 and Angular 12.

Related