Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using throttleTime function on subject angular2 error

I'm trying to use throttleTime operator on a subject. I have imported the operator. I'm getting this error: this.cropSubject.asObservable(...).throttleTime is not a function. I can't figure out what is going wrong. Is this a bug?

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);
    })
}
like image 325
quantdaddy Avatar asked Jun 11 '26 04:06

quantdaddy


1 Answers

You want to add the operator. You're just importing the implementation.

import 'rxjs/add/operator/throttleTime';

It will add the throttleTime operator to the prototype.

like image 137
Ben Lesh Avatar answered Jun 14 '26 00:06

Ben Lesh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!