在 angular 2 组件中使用 rxjs,我应该手动导入运算符吗?

Using rxjs in angular 2 component, should I manually import the operators?

http 的文档有 this example:

import {Http, HTTP_PROVIDERS} from 'angular2/http';

@Component({
  selector: 'http-app',
  viewProviders: [HTTP_PROVIDERS],
  templateUrl: 'people.html'
})

class PeopleComponent {
  constructor(http: Http) {
    http.get('people.son')]
        .map(res => res.json())
        .subscribe(people => this.people = people);
  }
}

但是,我需要添加这一行:import 'rxjs/add/operator/map 才能使其正常工作。

我的配置是否不同或示例中缺少导入?

Server Communication 开发指南discusses/mentions/explains 这个:

The RxJS library is quite large. Size matters when we build a production application and deploy it to mobile devices. We should include only those features that we actually need.

Accordingly, Angular exposes a stripped down version of Observable in the rxjs/Observable module, a version that lacks almost all operators including the ones we'd like to use here such as the map method...

It's up to us to add the operators we need. We could add each operator, one-by-one, until we had a custom Observable implementation tuned precisely to our requirements.

例如,如您所述,明确添加地图:

import 'rxjs/add/operator/map';

或者,如果我们懒惰,我们可以直接引入全套运算符:

import 'rxjs/Rx';