New to RxJS, range is not a function

Viewed 1998

I'm trying to create a simple TypeScript file to use RxJS. Here is what I did:

"npm install rxjs", referenced "traceur & systemjs" in my "index.html" and created a "test.ts" file with this:

import {Observable} from 'rxjs/Rx';

Observable.range(1, 2, 3, 4, 5)
    .map(x => x * 2)
    .filter(x => x > 5)
    .subscribe(
        x => console.log(x),
        err => console.log('Error'),
        ok => console.log('No error')
    );

I'm configuring systemjs like this:

System.config({
    defaultJSExtensions: true,
    map: {
        'rxjs': 'node_modules/rxjs'
    }
});

System.import('test');

According to the documentation, the "Observable" type should contains a "range" method but apparently, it does only contain the "Create" one... Therefore, I got the error "Error: TypeError: Observable_1.Observable.fromArray is not a function".

I'm quite new in all this "TypeScript/systemjs/rxjs" stuff so I'm sorry if my question is stupid :-D

2 Answers

For rxjs 6.*

import { range } from "rxjs";

const observable = range(0, 4);
Related