Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 检查debounceTime()进程中是否可观察到_Javascript_Typescript_Rxjs_Observable_Subject - Fatal编程技术网

Javascript 检查debounceTime()进程中是否可观察到

Javascript 检查debounceTime()进程中是否可观察到,javascript,typescript,rxjs,observable,subject,Javascript,Typescript,Rxjs,Observable,Subject,仅当主题处于去抖动过程中时,如何才能对其执行.next() let someFlag = true; if (someFlag) { someFlag = false; if (this.resizeDebouncer !== null)) { this.resizeDebouncer = new Subject<Event>(); this.resizeDebouncer.pipe(

仅当
主题
处于去抖动过程中时,如何才能对其执行
.next()

let someFlag = true;
if (someFlag) {
    someFlag = false;
        if (this.resizeDebouncer !== null)) {
            this.resizeDebouncer = new Subject<Event>();
            this.resizeDebouncer.pipe(
                debounceTime(1000)
            ).subscribe(e => console.log(e.type));
        }

    }
this.resizeDebouncer.next(event); // should be executed only if resizeDebouncer subject in debouncing progress. 
// Don't execute if nothing is running
让someFlag=true;
if(someFlag){
someFlag=false;
如果(this.resizeDebouncer!==null)){
this.resizeDebouncer=新主题();
这是一个大口径的烟斗(
去BounceTime(1000)
).subscribe(e=>console.log(e.type));
}
}
this.resizeDebouncer.next(event);//只有在取消公告过程中重新调整公告者主题时才应执行。
//如果没有任何运行,则不执行

我没有找到任何正在进行的去抖动标记。
.isClosed
.isStopped
都不适合。但我已经解决了我的问题,每次在订阅中取消订阅
Subject
。在这种情况下,订阅仅存在于取消绑定进度范围内,而在其他时间
。next()
不起任何作用

let subscription = this.resizeDebouncer
    .pipe(debounceTime(300))
    .subscribe(e => {
        subscription.unsubscribe();
        e => console.log(e.type);
    });