Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RxJS: How to import Just

I'd like to use RxJS's just.
What I need it for is Observable.just(null), which can't be done with Observable.from().

I'm trying

import 'rxjs/add/operator/just';

But it's not present in where it should be - node_modules/rxjs/add/operator, so this fails to compile.

How can I add this operator?

like image 529
Ondra Žižka Avatar asked Dec 18 '22 11:12

Ondra Žižka


1 Answers

That depends on the version of Rx.js:

  • 4.0 includes a .just method;
  • 5.0 doesn't. Instead, use the .of method.

Like this:

Rx.Observable.of(null).forEach(x => console.log(x))
like image 87
thalesmello Avatar answered Jan 14 '23 06:01

thalesmello