Hongbo Miao
Hongbo Miao

Reputation: 49824

How to use RxJS in an angular2-meteor project?

I have an angular2-meteor project.

I tried to use RxJS, so I added these in my code:

import {Observable} from 'rxjs/Observable';
import 'rxjs/Rx';

But when I run it, it shows:

Cannot find module 'rxjs/Observable'.

Do I need install any package from Atmosphere?

Upvotes: 3

Views: 892

Answers (1)

Thierry Templier
Thierry Templier

Reputation: 202216

You should this import:

import {Observable} from 'rxjs/Rx';
import 'rxjs/add/operator/map'; // for example to add a specific operator

instead of this one:

import {Observable} from 'rxjs/Observable';

I don't Atmosphere but this package is what you define in the package.json file:

{
  "name": "apispark-angular2",
  (...)
  "dependencies": {
    "angular2": "2.0.0-beta.0",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.0",  <---------------
    "systemjs": "0.19.6",
    "zone.js": "0.5.10"
  },
  (...)
}

You need it to make work Angular2. For example class EventEmitter class extends the Subject class that is part of the rxjs library...

Upvotes: 1

Related Questions