Skip to content

Commit

Permalink
take(1) to unsubscribe automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Slawomir Wieczorek committed Nov 28, 2024
1 parent e06340f commit 871ea31
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
import {HideAllCurrentPublishedAnnouncementsService} from "../hide-all-current-published-announcements.service";
import {selectUrl} from "../../../../store/router/router.selectors";
import {naviElements} from "../../../../app-navi-elements";
import {take} from "rxjs/operators";

@Component({
providers: [DialogService],
Expand Down Expand Up @@ -99,7 +100,7 @@ export class PublishedAnnouncementsWrapperComponent implements AfterViewInit {
this.hideAllCurrentAnnouncementsService.hide = false;
}
});
const subscription = this.ref.onClose.subscribe(() => {
this.ref.onClose.pipe(take(1)).subscribe(() => {
if (this.hideAllCurrentAnnouncementsService.hide) {
for (const announcement of announcements) {
this.hide(announcement);
Expand All @@ -108,11 +109,6 @@ export class PublishedAnnouncementsWrapperComponent implements AfterViewInit {
}
});

this.ref.onDestroy.subscribe(() => {
if (subscription) {
subscription.unsubscribe()
}
});
}

}

0 comments on commit 871ea31

Please sign in to comment.