Javascript 在角度测量中使用去BounceTime

Javascript 在角度测量中使用去BounceTime,javascript,angular,typescript,rxjs,Javascript,Angular,Typescript,Rxjs,我想使用debounceTime在按键300毫秒后向服务器发送请求 我使用以下代码: GetUsers(): void { let value = document.getElementById('search-box'); this.cdRef.detectChanges(); if (this.subscription) { this.subscription.unsubscribe(); } value = this.search

我想使用
debounceTime
在按键300毫秒后向服务器发送请求

我使用以下代码:

GetUsers(): void {
    let value = document.getElementById('search-box');
    this.cdRef.detectChanges();

    if (this.subscription) {
        this.subscription.unsubscribe();
    }

    value = this.searchValue.toString();

    const typeahead = fromEvent(value, 'input').pipe(
        map((e: KeyboardEvent) => (e.target as HTMLInputElement).value),
        filter(text => text.length > 2),
        debounceTime(10),
        distinctUntilChanged(),
        x => {
            if (value.startsWith('@')) {
                this.searchTitle = 'GENERAL.USER_NAME';
                const val = value.slice(1);
                if (val.length > 0) {

                    this.getWithUserName(val, this.page);

                }
            } else if (value.startsWith('+9')) {

                this.searchTitle = 'GENERAL.PHONE_NUMBER';
                this.GetWithPhoneNumber(this.searchValue, this.page);

            } else if (!value.startsWith('@') && !value.startsWith('+9')) {
                this.searchTitle = 'GENERAL.NAME';
                this.GetWithDisplayName(value, this.page);

            }
        }
    );
    this.cdRef.detectChanges();
}
这是用于向服务器发送请求的代码
HttpClient

getWithUserName(value: string, page: number): void {
    this.loading = true;
    this.cdRef.detectChanges();
    this.subscription = this.userPublicService
        .getUserByUserName(value, page, this.appConfig.dropdownPageSize)
        .pipe(debounceTime(30000),
            distinctUntilChanged())
        .subscribe(data => {
            this.users = data['records'];
            this.totalCount = data['totalCount'];
            this.cdRef.detectChanges();
            this.loading = false;
            this.ValidateshowBtn();
        });
    if (this.userId > 0) {
        this.selectedUserById(this.userId);
    }
}
但是这个代码不适合我

有什么问题吗?我怎样才能解决这个问题

它显示了以下错误:

src/app/shared/components/user mutli select search/user mutli select search.component.ts(117,4)中出错:错误TS2345:类型为“(x:Observable)=>void”的参数不能分配给类型为“OperatorFunction”的参数。 类型“void”不可分配给类型“Observable”


x=>{
开头的函数应该在
tap()
中,或者在
subscribe()

中。您需要进一步调试它,以准确地隔离“不起作用的内容”。您可能已经这样做了,但“所有这些对我来说都不起作用”太模糊了。什么起作用?它起什么作用?问题在哪里?把它缩小到确切的问题和最小的复制者。@JoshWulf它显示了这个错误。我更新了问题好的,太好了!那么你发布的代码中的(117)是哪一行?或者返回一个可观察的。