RxJS:如何导入 Just

RxJS: How to import Just

我想使用 RxJS 的 just
我需要的是Observable.just(null),用Observable.from().

做不到

我正在尝试

import 'rxjs/add/operator/just';

但是它没有出现在它应该出现的位置 - node_modules/rxjs/add/operator,所以编译失败。

如何添加这个操作员?

这取决于Rx.js的版本:

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

像这样:

Rx.Observable.of(null).forEach(x => console.log(x))