Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(toggle): update overlay subscription filter to tuple #2898

Merged
merged 1 commit into from
Nov 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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