Skip to content

Commit

Permalink
fix: revert SubjectUnsubscribedChecker (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
arturovt committed May 3, 2022
1 parent 1328bfe commit b1e1955
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 244 deletions.
20 changes: 1 addition & 19 deletions apps/integration/src/app/inheritance/inheritance.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,13 @@
with `@UntilDestroy()` but directive is not
</li>
<li>
`Issue97Component` extends from `Issue97Directive`. Directive is decorated with
`Issue97Component` extends from the `Issue97Directive`. Directive is decorated with
`@UntilDestroy()` but component is not
</li>
<li>
`Issue175Component` extends from the `Issue175Directive`. Directive is decorated with
`@UntilDestroy()` and the `Issue175Component` implements its own `ngOnDestroy()`
method. The `Issue175Directive.ngOnDestroy()` will not be called, because
`Issue175Component.ngOnDestroy()` does not call `super.ngOnDestroy()`.
</li>
</ol>

<app-issue-61 *ngIf="issue61Shown"></app-issue-61>
<app-issue-97 *ngIf="issue97Shown"></app-issue-97>
<app-issue-175 *ngIf="issue175Shown"></app-issue-175>

<div data-cy="issue-61-status" [class]="issue61StatusClass$ | async">
Issue#61: {{ issue61StatusText$ | async }}
Expand All @@ -33,10 +26,6 @@
<div data-cy="issue-97-status" [class]="issue97StatusClass$ | async">
Issue#97: {{ issue97StatusText$ | async }}
</div>

<div data-cy="issue-175-status" [class]="issue175StatusClass$ | async">
Issue#175: {{ issue175StatusText$ | async }}
</div>
</div>
</div>

Expand All @@ -46,11 +35,4 @@
<button data-cy="toggle-issue-97" class="button is-link is-light" (click)="toggleIssue97()">
Toggle issue#97
</button>
<button
data-cy="toggle-issue-175"
class="button is-link is-light"
(click)="toggleIssue175()"
>
Toggle issue#175
</button>
</div>
19 changes: 0 additions & 19 deletions apps/integration/src/app/inheritance/inheritance.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { NotificationClass, NotificationText } from '../enums/notification.enum'
export class InheritanceComponent {
issue61Shown = true;
issue97Shown = true;
issue175Shown = true;

issue61Status$ = new BehaviorSubject({
directiveUnsubscribed: false,
Expand Down Expand Up @@ -55,29 +54,11 @@ export class InheritanceComponent {
)
);

issue175Status$ = new BehaviorSubject({ componentUnsubscribed: false });

issue175StatusClass$ = this.issue175Status$.pipe(
map(({ componentUnsubscribed }) =>
componentUnsubscribed ? NotificationClass.Success : NotificationClass.Danger
)
);

issue175StatusText$ = this.issue175Status$.pipe(
map(({ componentUnsubscribed }) =>
componentUnsubscribed ? NotificationText.Unsubscribed : NotificationText.Subscribed
)
);

toggleIssue61(): void {
this.issue61Shown = !this.issue61Shown;
}

toggleIssue97(): void {
this.issue97Shown = !this.issue97Shown;
}

toggleIssue175(): void {
this.issue175Shown = !this.issue175Shown;
}
}
3 changes: 1 addition & 2 deletions apps/integration/src/app/inheritance/inheritance.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { InheritanceComponent } from './inheritance.component';

import { Issue61Component } from './issue-61/issue-61.component';
import { Issue97Component } from './issue-97/issue-97.component';
import { Issue175Component } from './issue-175/issue-175.component';

@NgModule({
imports: [
Expand All @@ -18,6 +17,6 @@ import { Issue175Component } from './issue-175/issue-175.component';
},
]),
],
declarations: [InheritanceComponent, Issue61Component, Issue97Component, Issue175Component],
declarations: [InheritanceComponent, Issue61Component, Issue97Component],
})
export class InheritanceModule {}

This file was deleted.

171 changes: 0 additions & 171 deletions libs/until-destroy/src/lib/checker.ts

This file was deleted.

12 changes: 0 additions & 12 deletions libs/until-destroy/src/lib/until-destroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@ import {
import { Subscription } from 'rxjs';

import { PipeType, isPipe } from './ivy';
import { createSubjectUnsubscribedChecker } from './checker';
import {
getSymbol,
UntilDestroyOptions,
completeSubjectOnTheInstance,
markAsDecorated,
} from './internals';

// This will be provided through Terser global definitions by Angular CLI. This will
// help to tree-shake away the code unneeded for production bundles.
declare const ngDevMode: boolean;

function unsubscribe(property: unknown): void {
if (property instanceof Subscription) {
property.unsubscribe();
Expand Down Expand Up @@ -71,9 +66,6 @@ function decoratePipe<T>(type: PipeType<T>, options: UntilDestroyOptions): void
}

export function UntilDestroy(options: UntilDestroyOptions = {}): ClassDecorator {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore The TS compiler throws 'typeof SubjectUnsubscribedChecker' is assignable to the constraint of type
// 'TFunction', but 'TFunction' could be instantiated with a different subtype of constraint 'Function'.
return (type: any) => {
if (isPipe(type)) {
decoratePipe(type, options);
Expand All @@ -82,9 +74,5 @@ export function UntilDestroy(options: UntilDestroyOptions = {}): ClassDecorator
}

markAsDecorated(type);

if (ngDevMode) {
return createSubjectUnsubscribedChecker(type);
}
};
}

0 comments on commit b1e1955

Please sign in to comment.