Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 508
Vik Avatar asked Jan 31 '23 02:01

Vik


1 Answers

You want the rxjs .of() method (https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/of.md) so you can return a observable that emits a boolean

return Observable.of(boolean);
like image 149
LLai Avatar answered Feb 02 '23 18:02

LLai