Skip to content

Commit

Permalink
fix: make ".dispose()" synchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed May 8, 2024
1 parent 5191399 commit fcffd4e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/core/utils/internal/Disposable.ts
@@ -1,9 +1,12 @@
export type DisposableSubscription = () => Promise<void> | void
export type DisposableSubscription = () => void

export class Disposable {
protected subscriptions: Array<DisposableSubscription> = []

public async dispose() {
await Promise.all(this.subscriptions.map((subscription) => subscription()))
public dispose() {
let subscription: DisposableSubscription | undefined
while ((subscription = this.subscriptions.shift())) {
subscription()
}
}
}

0 comments on commit fcffd4e

Please sign in to comment.