gpt4 book ai didi

angular - 在主题 angular2 错误上使用 throttleTime 函数

转载 作者:太空狗 更新时间:2023-10-29 19:28:35 25 4
gpt4 key购买 nike

我正在尝试对某个主题使用 throttleTime 运算符。我已经导入了运算符(operator)。我收到此错误:this.cropSubject.asObservable(...).throttleTime 不是函数。我不知道出了什么问题。这是一个错误吗?

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);
})
}

最佳答案

您想添加运算符(operator)。您只是在导入实现。

import 'rxjs/add/operator/throttleTime';

它将 throttleTime 运算符添加到原型(prototype)。

关于angular - 在主题 angular2 错误上使用 throttleTime 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45427457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com