Skip to content

Commit

Permalink
fix(rxjs): make unsubscribe more generic to avoid RxJS update issue
Browse files Browse the repository at this point in the history
- let's not use RxJS Subscription directly to avoid errors when upgrading RxJS, for example this error is caused by a version mismatch between Angular-Slickgrid and the demos:
"Type 'import("...dist/types/internal/Subscription").Subscription[]' is not assignable to type 'import(".../dist/types/internal/Subscription").Subscription[]'."
  • Loading branch information
ghiscoding committed Jan 5, 2023
1 parent 7ce5690 commit 14484ba
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/app/modules/angular-slickgrid/services/utilities.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { Subscription } from 'rxjs';

/**
* Unsubscribe all Observables Subscriptions
* It will return an empty array if it all went well
* @param subscriptions
*/
export function unsubscribeAllObservables(subscriptions: Subscription[]): Subscription[] {
export function unsubscribeAllObservables(subscriptions: Array<{ unsubscribe: ()=> void; }>): Array<{ unsubscribe: ()=> void; }> {
if (Array.isArray(subscriptions)) {
subscriptions.forEach((subscription: Subscription) => {
if (subscription && subscription.unsubscribe) {
let subscription = subscriptions.pop();
while (subscription) {
if (typeof subscription.unsubscribe === 'function') {
subscription.unsubscribe();
}
});
subscriptions = [];
subscription = subscriptions.pop();
}
}

return subscriptions;
Expand Down

0 comments on commit 14484ba

Please sign in to comment.