diff --git a/src/modules/autocomplete/autocomplete-input.directive.ts b/src/modules/autocomplete/autocomplete-input.directive.ts index bf9070224..746bdf48e 100644 --- a/src/modules/autocomplete/autocomplete-input.directive.ts +++ b/src/modules/autocomplete/autocomplete-input.directive.ts @@ -62,7 +62,7 @@ export class SkyAutocompleteInputDirective public textChanges = new EventEmitter(); public blur = new EventEmitter(); - private destroy = new Subject(); + private ngUnsubscribe = new Subject(); private _displayWith: string; private _value: any; @@ -78,7 +78,7 @@ export class SkyAutocompleteInputDirective Observable .fromEvent(element, 'keyup') - .takeUntil(this.destroy) + .takeUntil(this.ngUnsubscribe) .subscribe(() => { this.textChanges.emit({ value: this.elementRef.nativeElement.value @@ -87,15 +87,15 @@ export class SkyAutocompleteInputDirective Observable .fromEvent(element, 'blur') - .takeUntil(this.destroy) + .takeUntil(this.ngUnsubscribe) .subscribe(() => { this.checkValues(); }); } public ngOnDestroy(): void { - this.destroy.next(true); - this.destroy.unsubscribe(); + this.ngUnsubscribe.next(); + this.ngUnsubscribe.complete(); } public writeValue(value: any): void { diff --git a/src/modules/autocomplete/autocomplete.component.ts b/src/modules/autocomplete/autocomplete.component.ts index bda1734e0..95f237ba9 100644 --- a/src/modules/autocomplete/autocomplete.component.ts +++ b/src/modules/autocomplete/autocomplete.component.ts @@ -133,7 +133,7 @@ export class SkyAutocompleteComponent @ContentChild(SkyAutocompleteInputDirective) private inputDirective: SkyAutocompleteInputDirective; - private destroy = new Subject(); + private ngUnsubscribe = new Subject(); private isMouseEnter = false; private searchResultsIndex = 0; private searchText: string; @@ -160,21 +160,21 @@ export class SkyAutocompleteComponent Observable .fromEvent(element, 'keydown') - .takeUntil(this.destroy) + .takeUntil(this.ngUnsubscribe) .subscribe((event: KeyboardEvent) => { this.handleKeyDown(event); }); Observable .fromEvent(element, 'mouseenter') - .takeUntil(this.destroy) + .takeUntil(this.ngUnsubscribe) .subscribe(() => { this.isMouseEnter = true; }); Observable .fromEvent(element, 'mouseleave') - .takeUntil(this.destroy) + .takeUntil(this.ngUnsubscribe) .subscribe(() => { this.isMouseEnter = false; }); @@ -192,13 +192,13 @@ export class SkyAutocompleteComponent this.inputDirective.displayWith = this.descriptorProperty; this.inputDirective.textChanges - .takeUntil(this.destroy) + .takeUntil(this.ngUnsubscribe) .subscribe((change: SkyAutocompleteInputTextChange) => { this.searchTextChanged(change.value); }); this.inputDirective.blur - .takeUntil(this.destroy) + .takeUntil(this.ngUnsubscribe) .subscribe(() => { if (!this.isMouseEnter) { this.searchText = ''; @@ -210,8 +210,8 @@ export class SkyAutocompleteComponent } public ngOnDestroy(): void { - this.destroy.next(true); - this.destroy.unsubscribe(); + this.ngUnsubscribe.next(); + this.ngUnsubscribe.complete(); } public onMenuChanges(change: SkyDropdownMenuChange): void { diff --git a/src/modules/dropdown/dropdown-menu.component.ts b/src/modules/dropdown/dropdown-menu.component.ts index b2d50a226..1728ea450 100644 --- a/src/modules/dropdown/dropdown-menu.component.ts +++ b/src/modules/dropdown/dropdown-menu.component.ts @@ -56,7 +56,8 @@ export class SkyDropdownMenuComponent implements AfterContentInit, OnDestroy { @ContentChildren(SkyDropdownItemComponent) public menuItems: QueryList; - private destroy = new Subject(); + private ngUnsubscribe = new Subject(); + private get hasFocusableItems(): boolean { const found = this.menuItems.find(item => item.isFocusable()); return (found !== undefined); @@ -73,7 +74,7 @@ export class SkyDropdownMenuComponent implements AfterContentInit, OnDestroy { /* istanbul ignore else */ if (this.dropdownComponent) { this.dropdownComponent.messageStream - .takeUntil(this.destroy) + .takeUntil(this.ngUnsubscribe) .subscribe((message: SkyDropdownMessage) => { /* tslint:disable-next-line:switch-default */ switch (message.type) { @@ -97,7 +98,7 @@ export class SkyDropdownMenuComponent implements AfterContentInit, OnDestroy { }); this.menuChanges - .takeUntil(this.destroy) + .takeUntil(this.ngUnsubscribe) .subscribe((change: SkyDropdownMenuChange) => { // Close the dropdown when a menu item is selected. if (change.selectedItem) { @@ -118,7 +119,7 @@ export class SkyDropdownMenuComponent implements AfterContentInit, OnDestroy { // Reset dropdown whenever the menu items change. this.menuItems.changes - .takeUntil(this.destroy) + .takeUntil(this.ngUnsubscribe) .subscribe((items: QueryList) => { this.reset(); this.menuChanges.emit({ @@ -128,8 +129,8 @@ export class SkyDropdownMenuComponent implements AfterContentInit, OnDestroy { } public ngOnDestroy() { - this.destroy.next(true); - this.destroy.unsubscribe(); + this.ngUnsubscribe.next(); + this.ngUnsubscribe.complete(); } @HostListener('click', ['$event']) diff --git a/src/modules/dropdown/dropdown.component.ts b/src/modules/dropdown/dropdown.component.ts index c64f3fb6f..b37fc0bd8 100644 --- a/src/modules/dropdown/dropdown.component.ts +++ b/src/modules/dropdown/dropdown.component.ts @@ -92,7 +92,7 @@ export class SkyDropdownComponent implements OnInit, OnDestroy { @ViewChild(SkyPopoverComponent) private popover: SkyPopoverComponent; - private destroy = new Subject(); + private ngUnsubscribe = new Subject(); private isKeyboardActive = false; private isOpen = false; @@ -107,15 +107,15 @@ export class SkyDropdownComponent implements OnInit, OnDestroy { public ngOnInit() { this.messageStream - .takeUntil(this.destroy) + .takeUntil(this.ngUnsubscribe) .subscribe((message: SkyDropdownMessage) => { this.handleIncomingMessages(message); }); } public ngOnDestroy() { - this.destroy.next(true); - this.destroy.unsubscribe(); + this.ngUnsubscribe.next(); + this.ngUnsubscribe.complete(); } @HostListener('keydown', ['$event']) diff --git a/src/modules/flyout/flyout.component.ts b/src/modules/flyout/flyout.component.ts index cbe76c269..d852b5784 100644 --- a/src/modules/flyout/flyout.component.ts +++ b/src/modules/flyout/flyout.component.ts @@ -71,7 +71,7 @@ export class SkyFlyoutComponent implements OnDestroy, OnInit { private flyoutHeader: ElementRef; private flyoutInstance: SkyFlyoutInstance; - private destroy = new Subject(); + private ngUnsubscribe = new Subject(); private _messageStream = new Subject(); @@ -83,7 +83,7 @@ export class SkyFlyoutComponent implements OnDestroy, OnInit { ) { // All commands flow through the message stream. this.messageStream - .takeUntil(this.destroy) + .takeUntil(this.ngUnsubscribe) .subscribe((message: SkyFlyoutMessage) => { this.handleIncomingMessages(message); }); @@ -94,8 +94,8 @@ export class SkyFlyoutComponent implements OnDestroy, OnInit { } public ngOnDestroy() { - this.destroy.next(true); - this.destroy.unsubscribe(); + this.ngUnsubscribe.next(); + this.ngUnsubscribe.complete(); } public onCloseButtonClick() { @@ -165,7 +165,7 @@ export class SkyFlyoutComponent implements OnDestroy, OnInit { instance.componentInstance = component; instance.hostController - .takeUntil(this.destroy) + .takeUntil(this.ngUnsubscribe) .subscribe((message: SkyFlyoutMessage) => { this.messageStream.next(message); }); diff --git a/src/modules/list-view-grid/list-view-grid.component.ts b/src/modules/list-view-grid/list-view-grid.component.ts index 67272ce88..4b6e145ad 100644 --- a/src/modules/list-view-grid/list-view-grid.component.ts +++ b/src/modules/list-view-grid/list-view-grid.component.ts @@ -109,7 +109,7 @@ export class SkyListViewGridComponent @ContentChildren(SkyGridColumnComponent, {descendants: true}) private columnComponents: QueryList; - private destroy = new Subject(); + private ngUnsubscribe = new Subject(); constructor( state: ListState, @@ -200,8 +200,8 @@ export class SkyListViewGridComponent } public ngOnDestroy() { - this.destroy.next(true); - this.destroy.unsubscribe(); + this.ngUnsubscribe.next(); + this.ngUnsubscribe.complete(); } public columnIdsChanged(selectedColumnIds: Array) { @@ -256,7 +256,7 @@ export class SkyListViewGridComponent // Watch for column heading changes: this.columnComponents.forEach((comp: SkyGridColumnComponent) => { comp.headingModelChanges - .takeUntil(this.destroy) + .takeUntil(this.ngUnsubscribe) .subscribe((change: SkyGridColumnHeadingModelChange) => { this.gridComponent.updateColumnHeading(change); });