2

Cannot find select operator from rxjs library.

As I understand and explained here, ngrx store uses select operator from rxjs library when we call store.select method. The way it is currently working is if I imort the whole rxjs library:

import 'rxjs/Rx';

But this imports the whole rxjs operators, I only want to import the operators I need.

If I exclude rxjs/Rx import, get this error:

TypeError: this.store.select(...).first is not a function

I have also done a global search in npm rxjs package directory and that folder doesn't have any file with select in it. Really confusing.

Community
  • 1
  • 1
Nexus23
  • 6,195
  • 9
  • 50
  • 67
  • 1
    The `select` operator is part of [`@ngrx/core`](https://github.com/ngrx/core/blob/v1.2.0/src/operator/select.ts) and is [bound to the `Store`](https://github.com/ngrx/store/blob/v2.2.1/src/store.ts#L23). Your error relates to the `first` operator, as Martin has pointed out in his answer. – cartant Mar 14 '17 at 21:08
  • Thanks @cartant, I missed that. – Nexus23 Mar 14 '17 at 21:15

2 Answers2

2

If you don't want to import the entire library you can pick only the operators/Observables you want with for example:

import 'rxjs/add/operator/first';

You can see the full list here: https://github.com/ReactiveX/rxjs/tree/master/src/add/operator

martin
  • 93,354
  • 25
  • 191
  • 226
0

Please try as well

npm un --save rxjs
npm un --save rxjs-compat

npm i --save rxjs@6.2.2
npm i --save rxjs-compat@6.2.2
Gopala Raja Naika
  • 2,321
  • 23
  • 18