Using throttleTime function on angular2 object error

I am trying to use the throttleTime operator on an object. I have imported the operator. I get this error: this.cropSubject.asObservable(...).throttleTime is not a function

. I can't figure out what's going wrong. This is mistake?

import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { throttleTime } from 'rxjs/operator/throttleTime';


export class EditItemComponent implements OnInit, AfterViewInit{


    cropSubject: Subject<string> = new Subject<string>();


    constructor(private taggingDataService: TaggingDataService, private _elementRef : ElementRef) {
    taggingDataService.selectedTags.subscribe((newTags) => {
        this.selectedTags = newTags;
    })
    this.cropSubject.asObservable().throttleTime(1000).subscribe((croppedImageSrc) => {
        this.updateImageData(croppedImageSrc);
    })
}

      

+3


source to share


1 answer


You want to add an operator. You are just importing the implementation.

import 'rxjs/add/operator/throttleTime';

      



It will add an operator to the prototype throttleTime

.

+1


source







All Articles