I am having issue with importing Observable.of
function in my project. My Intellij sees everything. In my code I have:
import {Observable} from
Somehow even Webstorm made it like this import {of} from 'rxjs/observable/of';
and everything started to work
RxJS 6
When upgrading to version 6 of the RxJS
library and not using the rxjs-compat
package the following code
import 'rxjs/add/observable/of';
// ...
return Observable.of(res);
has to be changed into
import { of } from 'rxjs';
// ...
return of(res);
In rxjs
v6, of
operator should be imported as import { of } from 'rxjs';
I had this problem today. I'm using systemjs to load the dependencies.
I was loading the Rxjs like this:
...
paths: {
"rxjs/*": "node_modules/rxjs/bundles/Rx.umd.min.js"
},
...
Instead of use paths use this:
var map = {
...
'rxjs': 'node_modules/rxjs',
...
}
var packages = {
...
'rxjs': { main: 'bundles/Rx.umd.min.js', defaultExtension: 'js' }
...
}
This little change in the way systemjs loads the library fixed my problem.
This should work properly just try it.
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
Actually I have imports messed up. In latest version of RxJS we can import it like that:
import 'rxjs/add/observable/of';