Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Renamed destroy stream to ngUnsubscribe #1527

Merged
merged 8 commits into from
Mar 28, 2018
10 changes: 5 additions & 5 deletions src/modules/autocomplete/autocomplete-input.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class SkyAutocompleteInputDirective
public textChanges = new EventEmitter<SkyAutocompleteInputTextChange>();
public blur = new EventEmitter<void>();

private destroy = new Subject<boolean>();
private ngUnsubscribe = new Subject();
private _displayWith: string;
private _value: any;

Expand All @@ -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
Expand All @@ -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 {
Expand Down
16 changes: 8 additions & 8 deletions src/modules/autocomplete/autocomplete.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class SkyAutocompleteComponent
@ContentChild(SkyAutocompleteInputDirective)
private inputDirective: SkyAutocompleteInputDirective;

private destroy = new Subject<boolean>();
private ngUnsubscribe = new Subject();
private isMouseEnter = false;
private searchResultsIndex = 0;
private searchText: string;
Expand All @@ -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;
});
Expand All @@ -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 = '';
Expand All @@ -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 {
Expand Down
13 changes: 7 additions & 6 deletions src/modules/dropdown/dropdown-menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export class SkyDropdownMenuComponent implements AfterContentInit, OnDestroy {
@ContentChildren(SkyDropdownItemComponent)
public menuItems: QueryList<SkyDropdownItemComponent>;

private destroy = new Subject<boolean>();
private ngUnsubscribe = new Subject();

private get hasFocusableItems(): boolean {
const found = this.menuItems.find(item => item.isFocusable());
return (found !== undefined);
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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<SkyDropdownItemComponent>) => {
this.reset();
this.menuChanges.emit({
Expand All @@ -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'])
Expand Down
8 changes: 4 additions & 4 deletions src/modules/dropdown/dropdown.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class SkyDropdownComponent implements OnInit, OnDestroy {
@ViewChild(SkyPopoverComponent)
private popover: SkyPopoverComponent;

private destroy = new Subject<boolean>();
private ngUnsubscribe = new Subject();
private isKeyboardActive = false;
private isOpen = false;

Expand All @@ -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'])
Expand Down
10 changes: 5 additions & 5 deletions src/modules/flyout/flyout.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class SkyFlyoutComponent implements OnDestroy, OnInit {
private flyoutHeader: ElementRef;

private flyoutInstance: SkyFlyoutInstance<any>;
private destroy = new Subject<boolean>();
private ngUnsubscribe = new Subject();

private _messageStream = new Subject<SkyFlyoutMessage>();

Expand All @@ -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);
});
Expand All @@ -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() {
Expand Down Expand Up @@ -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);
});
Expand Down
8 changes: 4 additions & 4 deletions src/modules/list-view-grid/list-view-grid.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class SkyListViewGridComponent
@ContentChildren(SkyGridColumnComponent, {descendants: true})
private columnComponents: QueryList<SkyGridColumnComponent>;

private destroy = new Subject<boolean>();
private ngUnsubscribe = new Subject();

constructor(
state: ListState,
Expand Down Expand Up @@ -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<string>) {
Expand Down Expand Up @@ -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);
});
Expand Down