I am just started learning angular2 and I am trying to do sample of RxJs using angular2. It would be highly appreciated, If some one help me.
RxJs Code-
var obs = Rx.Observable.interval(500)
.take(5)
.do(i => console.log(i) );
package.json
{
"name": "angular-quickstart",
"version": "1.0.0",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
},
"license": "ISC",
"dependencies": {
"@angular/common": "~2.0.1",
"@angular/compiler": "~2.0.1",
"@angular/core": "~2.0.1",
"@angular/forms": "~2.0.1",
"@angular/http": "~2.0.1",
"@angular/platform-browser": "~2.0.1",
"@angular/platform-browser-dynamic": "~2.0.1",
"@angular/router": "~3.0.1",
"@angular/upgrade": "~2.0.1",
"angular-in-memory-web-api": "~0.1.1",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.39",
"zone.js": "^0.6.25"
},
"devDependencies": {
"concurrently": "^3.0.0",
"lite-server": "^2.2.2",
"typescript": "^2.0.3",
"typings":"^1.4.0"
}
}
Update 2020:
For those using the CDN listed on their readme, i.e. https://unpkg.com/rxjs/bundles/rxjs.umd.min.js
.
The developers must have changed the global namespace for rxjs from Rx
to rxjs
, so use rxjs
instead of Rx
,
var obs = rxjs.Observable.interval(500)
.take(5)
.do(i => console.log(i) );
For more information, read the rxjs's README.md
I just removed the Rx before Observable-
var obs = Observable.interval(500)
.take(5)
.do(i => console.log(i) );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With