Skip to content

Commit

Permalink
fix(cdk): unsubscribe from swipe service when directive is destroyed
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Sep 14, 2024
1 parent 354f58e commit 2c3f814
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion projects/cdk/directives/swipe/swipe.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {DOCUMENT} from '@angular/common';
import {inject, Injectable} from '@angular/core';
import {DestroyRef, inject, Injectable} from '@angular/core';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {tuiTypedFromEvent} from '@taiga-ui/cdk/observables';
import {tuiInjectElement} from '@taiga-ui/cdk/utils/dom';
import {tuiIsPresent} from '@taiga-ui/cdk/utils/miscellaneous';
Expand All @@ -13,6 +14,7 @@ export class TuiSwipeService extends Observable<TuiSwipeEvent> {
constructor() {
const doc = inject(DOCUMENT);
const el = tuiInjectElement();
const destroyRef = inject(DestroyRef);
const {timeout, threshold} = inject(TUI_SWIPE_OPTIONS);

super((subscriber) => {
Expand Down Expand Up @@ -52,6 +54,7 @@ export class TuiSwipeService extends Observable<TuiSwipeEvent> {
return null;
}),
filter(tuiIsPresent),
takeUntilDestroyed(destroyRef),
)
.subscribe(subscriber);
});
Expand Down

0 comments on commit 2c3f814

Please sign in to comment.