我正在尝试对某个主题使用throttleTime运算符。我已导入运营商。我收到此错误:this.cropSubject.asObservable(...).throttleTime is not a function
。我无法弄清楚出了什么问题。这是一个错误吗?
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);
})
}
答案 0 :(得分:1)
您想要添加运算符。您只是导入实施。
import 'rxjs/add/operator/throttleTime';
它会将throttleTime
运算符添加到原型中。