From c0e914a6a6da1b345ddb7869cbc669df4445f75f Mon Sep 17 00:00:00 2001 From: Blackbaud-SteveBrush Date: Wed, 7 Mar 2018 10:20:22 -0500 Subject: [PATCH] Renamed destroy stream to ngUnsubscribe --- .../autocomplete/autocomplete-input.directive.ts | 10 +++++----- .../autocomplete/autocomplete.component.ts | 16 ++++++++-------- src/modules/dropdown/dropdown-menu.component.ts | 13 +++++++------ src/modules/dropdown/dropdown.component.ts | 8 ++++---- src/modules/flyout/flyout.component.ts | 10 +++++----- .../list-view-grid/list-view-grid.component.ts | 8 ++++---- src/modules/tokens/tokens.component.ts | 12 ++++++------ 7 files changed, 39 insertions(+), 38 deletions(-) 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 794a0e9aa..cce02f96e 100644 --- a/src/modules/autocomplete/autocomplete.component.ts +++ b/src/modules/autocomplete/autocomplete.component.ts @@ -127,7 +127,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; @@ -153,21 +153,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; }); @@ -185,13 +185,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 = ''; @@ -203,8 +203,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); }); diff --git a/src/modules/tokens/tokens.component.ts b/src/modules/tokens/tokens.component.ts index 21e4a0c9e..1059c90c4 100644 --- a/src/modules/tokens/tokens.component.ts +++ b/src/modules/tokens/tokens.component.ts @@ -13,7 +13,7 @@ import { ViewChildren } from '@angular/core'; -import { ReplaySubject } from 'rxjs/ReplaySubject'; +import { Subject } from 'rxjs/Subject'; import 'rxjs/add/operator/takeUntil'; import { @@ -69,7 +69,7 @@ export class SkyTokensComponent implements OnInit, OnChanges, OnDestroy { } @Input() - public messageStream = new ReplaySubject(); + public messageStream = new Subject(); @Input() public set tokens(value: SkyToken[]) { @@ -113,7 +113,7 @@ export class SkyTokensComponent implements OnInit, OnChanges, OnDestroy { @ViewChildren(SkyTokenComponent) private tokenComponents: QueryList; - private destroyed = new ReplaySubject(); + private ngUnsubscribe = new Subject(); private _activeIndex: number; private _disabled: boolean; @@ -143,8 +143,8 @@ export class SkyTokensComponent implements OnInit, OnChanges, OnDestroy { } public ngOnDestroy() { - this.destroyed.next(true); - this.destroyed.unsubscribe(); + this.ngUnsubscribe.next(); + this.ngUnsubscribe.complete(); } public onTokenClick(token: SkyToken) { @@ -228,7 +228,7 @@ export class SkyTokensComponent implements OnInit, OnChanges, OnDestroy { private initMessageStream() { this.messageStream - .takeUntil(this.destroyed) + .takeUntil(this.ngUnsubscribe) .subscribe((message: SkyTokensMessage) => { /* tslint:disable-next-line:switch-default */ switch (message.type) {