(https://indepth.dev/posts/1518/takeuntildestroy-in-angular-v16)中的示例 这适用于一个订阅方法,但不适用于两个方法
如果您查看以下代码,那么当组件被销毁时,第二个订阅将存在.我只是不明白为什么以及如何让代码对组件中的任意数量的订阅起作用?也许我误解了什么?
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'
constructor(
) {
interval(1000).pipe(
takeUntilDestroyed(),
).subscribe(console.log)
interval(1000).pipe(
takeUntilDestroyed(),
).subscribe(console.log)
}