Skip to content

Commit

Permalink
Satisfy linter on unsubscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
jacogr committed Jan 24, 2024
1 parent 59edc71 commit 917c50b
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/api/src/promise/Combinator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class Combinator<T extends unknown[] = unknown[]> {
constructor (fns: (CombinatorFunction | [CombinatorFunction, ...unknown[]])[], callback: CombinatorCallback<T>) {
this.#callback = callback;

// eslint-disable-next-line @typescript-eslint/require-await
// eslint-disable-next-line @typescript-eslint/no-floating-promises, @typescript-eslint/require-await
this.#subscriptions = fns.map(async (input, index): UnsubscribePromise => {
const [fn, ...args] = Array.isArray(input)
? input
Expand Down Expand Up @@ -73,16 +73,19 @@ export class Combinator<T extends unknown[] = unknown[]> {

this.#isActive = false;

this.#subscriptions.map(async (subscription): Promise<void> => {
try {
const unsubscribe = await subscription;
Promise
.all(this.#subscriptions.map(async (subscription): Promise<void> => {
try {
const unsubscribe = await subscription;

if (isFunction(unsubscribe)) {
unsubscribe();
if (isFunction(unsubscribe)) {
unsubscribe();
}
} catch {
// ignore
}
} catch {
// ignore
}
});
})).catch(() => {
// ignore, already ignored above, should never throw
});
}
}

0 comments on commit 917c50b

Please sign in to comment.