<!DOCTYPE html>
<head>
<script src="https://cdn.jsdelivr.net/rxjs/4.1.0/rx.min.js"></script>
</head>
<body>
<script>
// `Rx` is available
var one$ = Rx.Observable.of(1);
var onesub = one$.subscribe(function (one) {
console.log(one); // 1
});
// alternatively: subscribe(console.log)
</script>
</body>
</html>
CDN if using RxJS 5 (RC):
<script src="https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.js"></script>
First install into your project directory with npm:
npm install rx
Or using RxJS 5 (RC):
npm install rxjs
Then, in your JavaScript file:
var Rx = require('rx');
//var Rx = require('rxjs/Rx'); // v5beta
var one$ = Rx.Observable.of(1);
var onesub = one$.subscribe(function (one) {
console.log(one); // 1
});
If using an es6/2015 compatible bundler:
import Rx from 'rx';
//import Rx from 'rxjs/Rx'; // v5beta
const one$ = Rx.Observable.of(1);
const onesub = one$.subscribe(one => console.log(one)); // 1