RxJS: How to import Just

1.5k Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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))