Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BehaviorSubject filter is not a function?

Tags:

angular

rxjs

Spend some time trying to figure out why my plunker doesn't work :(

https://plnkr.co/edit/JHODQeWQtYmz4UkYzFds?p=preview

error append on following line

let load = this.actions$.filter (action => return action.type==START_LOADING);

actions$ is defined like this :

private actions$ : BehaviorSubject<Action> = new BehaviorSubject<Action>({type: null, payload: null});

and I import this

import { Subject } from "rxjs/subject";
import { Observable } from "rxjs/Observable";
import { BehaviorSubject } from 'rxjs/subject/BehaviorSubject';

in debugger of Chrome, I see that some functions are available (map, lift, scan, etc) but not filter.

Somebody know why filter is not available on BehaviorSubject ? I imagine that is a simple mistake but I don't find it ;)

like image 704
Philippe sillon Avatar asked Feb 11 '16 18:02

Philippe sillon


1 Answers

I think that you should import the filter operator:

import 'rxjs/add/operator/filter';

Here is your updated plunkr with this import: https://plnkr.co/edit/37JEG4aQ7qmQuaPchB4Z?p=preview.

See this question for more details:

  • Angular 2 HTTP GET with TypeScript error http.get(...).map is not a function in [null]
like image 194
Thierry Templier Avatar answered Oct 05 '22 21:10

Thierry Templier