I am using SystemJS to load my es2015 project into the browser.
This is what I did
import {Observable} from 'rxjs/Rx'; const button = document.querySelector('button'); const start$ = Observable.fromEvent(button, 'click');
In this case, the Observable is undefined . So I tried
import Observable from 'rxjs/Observable';
In this case, Observable is an object, but Observable.fromEvent is undefined (it seems empty)
Finally i did
import Rx from 'rxjs/Rx'
which really worked. Any ideas why the other two didn't work? I saw the code in which they used them. What would be the preferred way to import Observable ?
UPDATE: as indicated below, all of this is described in README . However, if I do,
import { Observable } from 'rxjs/Observable'; import 'rxjs/add/observable/fromEvent'; const start$ = Observable.fromEvent(startButton, 'click');
I get Observable is undefined . And if I do
import Observable from 'rxjs/Observable';
the Observable is an empty object. fromEvent not added.
I am using RxJs 5.1.1, and here is my part of index.html / systemjs:
<script src="./node_modules/systemjs/dist/system.js"></script> <script> SystemJS.config({ baseURL: 'node_modules', packages: { '.': { defaultJSExtensions: 'js' } }, map: { 'plugin-babel': 'systemjs-plugin-babel/plugin-babel.js', 'systemjs-babel-build': 'systemjs-plugin-babel/systemjs-babel-browser.js' }, transpiler: 'plugin-babel' }); SystemJS.import('/js/main.js'); </script>