3
votes

I was trying to follow along with the official Angular tutorial on practical observable usage and attempted to import the "fromEvent":

import { fromEvent } from 'rxjs';

However, it keeps throwing an error message which states "myApp/node_modules/rxjs/Rx" has no exported member 'fromEvent'

I've already searched SO and Googled, with no luck.

1
First Google search shows this, where it's imported from a subfolder, does that work? What version of rxjs? - Phix
Wow, that was fast! My Google-foo is not up to snuff: What was your search string? And yes, that helps tremendously! - Justin F
fromEvent rxjs, glad it helped! - Phix

1 Answers

7
votes

'fromEvent' appears to be part of Observable. You can import it like this:

import { fromEvent } from 'rxjs/observable/fromEvent';

Unlike answers elsewhere, importing "Observable" did not help, and I had to rely on VS code correctly auto suggesting where to import from (After spending quite a bit of time trying to figure out why the import did not work).