离子平台:"Resize ready" 带去抖时间管道

Ionic platform: "Resize ready" with debounce time pipe

我尝试使用 Ionics platform 调整大小事件来创建 "resize ready" 事件。我尝试使用 rxjs debounceTime 函数仅在调整大小完成时产生一个事件。

这是我组件"ngOnInit"中的代码

// Reset ingredients on resize ready
this.platform.resize.subscribe(async () => {
  console.log("Resize");
});

this.platform.resize.pipe(debounceTime(500)).subscribe(async () => {
  console.log("Resize ready");
});

"resize" 像预期的那样在调整 window 大小时输出很多。调整大小完成后输出 "Resize ready",如预期。

但是: resize ready输出12次

有没有人知道,为什么它被触发了 12 次?我希望它只显示一次。

好的,简单的解决方案:我的页面上有 12 次该组件,所以一切都很好。

我会将此解决方案留在网上,供搜索如何为 ionic 创建 "Resize ready" 事件的人使用。