Skip to content

Commit

Permalink
refactor(toggle): update overlay subscription filter to tuple (#2898)
Browse files Browse the repository at this point in the history
  • Loading branch information
damyanpetev authored and kdinev committed Nov 13, 2018
1 parent c996f2f commit e651389
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { IgxNavigationService, IToggleView } from '../../core/navigation';
import { IgxOverlayService } from '../../services/overlay/overlay';
import { OverlaySettings, OverlayEventArgs, ConnectedPositioningStrategy, AbsoluteScrollStrategy } from '../../services';
import { filter, takeUntil } from 'rxjs/operators';
import { Subscription, OperatorFunction, Subject } from 'rxjs';
import { Subscription, Subject, MonoTypeOperatorFunction } from 'rxjs';
import { OverlayCancelableEventArgs } from '../../services/overlay/utilities';
import { CancelableEventArgs } from '../../core/utils';

Expand All @@ -28,8 +28,9 @@ import { CancelableEventArgs } from '../../core/utils';
export class IgxToggleDirective implements IToggleView, OnInit, OnDestroy {
private _overlayId: string;
private destroy$ = new Subject<boolean>();
private _overlaySubFilter: OperatorFunction<OverlayEventArgs, OverlayEventArgs>[] = [
filter(x => x.id === this._overlayId)
private _overlaySubFilter: [MonoTypeOperatorFunction<OverlayEventArgs>, MonoTypeOperatorFunction<OverlayEventArgs>] = [
filter(x => x.id === this._overlayId),
takeUntil(this.destroy$)
];
private _overlayOpenedSub: Subscription;
private _overlayClosingSub: Subscription;
Expand Down Expand Up @@ -189,12 +190,12 @@ export class IgxToggleDirective implements IToggleView, OnInit, OnDestroy {
}

this.unsubscribe();
this._overlayOpenedSub = this.overlayService.onOpened.pipe(...this._overlaySubFilter, takeUntil(this.destroy$)).subscribe(() => {
this._overlayOpenedSub = this.overlayService.onOpened.pipe(...this._overlaySubFilter).subscribe(() => {
this.onOpened.emit();
});
this._overlayClosingSub = this.overlayService
.onClosing
.pipe(...this._overlaySubFilter, takeUntil(this.destroy$))
.pipe(...this._overlaySubFilter)
.subscribe((e: OverlayCancelableEventArgs) => {
const eventArgs: CancelableEventArgs = { cancel: false };
this.onClosing.emit(eventArgs);
Expand All @@ -208,7 +209,7 @@ export class IgxToggleDirective implements IToggleView, OnInit, OnDestroy {
}
});
this._overlayClosedSub = this.overlayService.onClosed
.pipe(...this._overlaySubFilter, takeUntil(this.destroy$))
.pipe(...this._overlaySubFilter)
.subscribe(this.overlayClosed);
}

Expand Down

0 comments on commit e651389

Please sign in to comment.