diff --git a/projects/s-ng-utils/src/lib/directive-superclass.ts b/projects/s-ng-utils/src/lib/directive-superclass.ts index f1843ab..877ec91 100644 --- a/projects/s-ng-utils/src/lib/directive-superclass.ts +++ b/projects/s-ng-utils/src/lib/directive-superclass.ts @@ -6,7 +6,7 @@ import { } from "@angular/core"; import { BehaviorSubject, Observable } from "rxjs"; import { filter, map } from "rxjs/operators"; -import { AutoDestroyable } from "./auto-destroyable"; +import { InjectableSuperclass } from "./injectable-superclass"; /** * Extend this when creating a directive (including a component, which is a kind of directive) to gain access to the helpers demonstrated below. **Warning:** You _must_ include a constructor in your subclass. @@ -45,10 +45,11 @@ import { AutoDestroyable } from "./auto-destroyable"; * } * ``` */ -export abstract class DirectiveSuperclass extends AutoDestroyable +export abstract class DirectiveSuperclass extends InjectableSuperclass implements OnChanges { - /** Emits the set of `@Input()` property names that change during each call to `ngOnChanges()`. */ - // lastChangedKeys$ = new Subject>(); + /** + * Emits the set of `@Input()` property names that change during each call to `ngOnChanges()`. + */ lastChangedKeys$ = new BehaviorSubject>(new Set()); protected changeDetectorRef: ChangeDetectorRef; diff --git a/projects/s-ng-utils/src/lib/form-control-superclass.spec.ts b/projects/s-ng-utils/src/lib/form-control-superclass.spec.ts index e65f334..8712fc2 100644 --- a/projects/s-ng-utils/src/lib/form-control-superclass.spec.ts +++ b/projects/s-ng-utils/src/lib/form-control-superclass.spec.ts @@ -9,12 +9,12 @@ import { import { FormsModule } from "@angular/forms"; import { By } from "@angular/platform-browser"; import { click, find, findButton } from "../test-helpers"; -import { AutoDestroyable } from "./auto-destroyable"; import { DirectiveSuperclass } from "./directive-superclass"; import { FormControlSuperclass, provideValueAccessor, } from "./form-control-superclass"; +import { InjectableSuperclass } from "./injectable-superclass"; @Component({ template: ` @@ -111,7 +111,7 @@ describe("FormControlSuperclass", () => { init(); const counter = fixture.debugElement.query(By.directive(CounterComponent)) .componentInstance; - expect(counter instanceof AutoDestroyable).toBe(true); + expect(counter instanceof InjectableSuperclass).toBe(true); expect(counter instanceof DirectiveSuperclass).toBe(true); })); }); diff --git a/projects/s-ng-utils/src/lib/auto-destroyable.spec.ts b/projects/s-ng-utils/src/lib/injectable-superclass.spec.ts similarity index 89% rename from projects/s-ng-utils/src/lib/auto-destroyable.spec.ts rename to projects/s-ng-utils/src/lib/injectable-superclass.spec.ts index 558f029..020f44e 100644 --- a/projects/s-ng-utils/src/lib/auto-destroyable.spec.ts +++ b/projects/s-ng-utils/src/lib/injectable-superclass.spec.ts @@ -7,16 +7,16 @@ import { import { By } from "@angular/platform-browser"; import { Subject } from "rxjs"; import { expectSingleCallAndReset } from "s-ng-dev-utils"; -import { AutoDestroyable } from "./auto-destroyable"; +import { InjectableSuperclass } from "./injectable-superclass"; @Injectable() -class DestroyableService extends AutoDestroyable {} +class DestroyableService extends InjectableSuperclass {} @Directive({ selector: `[sDestroyableDirective]`, providers: [DestroyableService], }) -class DestroyableDirective extends AutoDestroyable { +class DestroyableDirective extends InjectableSuperclass { constructor(subject: Subject, public service: DestroyableService) { super(); this.subscribeTo(subject); @@ -33,7 +33,7 @@ class TestComponent { showThings = true; } -describe("AutoDestroyable", () => { +describe("InjectableSuperclass", () => { let subject: Subject; let fixture: ComponentFixture; diff --git a/projects/s-ng-utils/src/lib/auto-destroyable.ts b/projects/s-ng-utils/src/lib/injectable-superclass.ts similarity index 91% rename from projects/s-ng-utils/src/lib/auto-destroyable.ts rename to projects/s-ng-utils/src/lib/injectable-superclass.ts index a218f0f..100a43f 100644 --- a/projects/s-ng-utils/src/lib/auto-destroyable.ts +++ b/projects/s-ng-utils/src/lib/injectable-superclass.ts @@ -10,7 +10,7 @@ import { SubscriptionManager } from "s-rxjs-utils"; * // or @Component() (also consider DirectiveSuperclass) * // or @Directive() (also consider DirectiveSuperclass) * // or @Pipe() - * class MyThing extends AutoDestroyable { + * class MyThing extends InjectableSuperclass { * constructor(somethingObservable: Observable) { * super(); * this.subscribeTo(somethingObservable); @@ -23,7 +23,7 @@ import { SubscriptionManager } from "s-rxjs-utils"; * } * ``` */ -export abstract class AutoDestroyable extends SubscriptionManager +export abstract class InjectableSuperclass extends SubscriptionManager implements OnDestroy { /** * An observable that emits once when this object is destroyed, then completes. diff --git a/projects/s-ng-utils/src/lib/wrapped-form-control-superclass.spec.ts b/projects/s-ng-utils/src/lib/wrapped-form-control-superclass.spec.ts index 9b6e7f5..aa2eae3 100644 --- a/projects/s-ng-utils/src/lib/wrapped-form-control-superclass.spec.ts +++ b/projects/s-ng-utils/src/lib/wrapped-form-control-superclass.spec.ts @@ -9,12 +9,12 @@ import { import { FormsModule, ReactiveFormsModule } from "@angular/forms"; import { By } from "@angular/platform-browser"; import { click, find, findButton, setValue } from "../test-helpers"; -import { AutoDestroyable } from "./auto-destroyable"; import { DirectiveSuperclass } from "./directive-superclass"; import { FormControlSuperclass, provideValueAccessor, } from "./form-control-superclass"; +import { InjectableSuperclass } from "./injectable-superclass"; import { WrappedFormControlSuperclass } from "./wrapped-form-control-superclass"; @Component({ @@ -163,7 +163,7 @@ describe("WrappedFormControlSuperclass", () => { init(); const component = fixture.debugElement.query(By.directive(StringComponent)) .componentInstance; - expect(component instanceof AutoDestroyable).toBe(true); + expect(component instanceof InjectableSuperclass).toBe(true); expect(component instanceof DirectiveSuperclass).toBe(true); expect(component instanceof FormControlSuperclass).toBe(true); })); diff --git a/projects/s-ng-utils/src/public-api.ts b/projects/s-ng-utils/src/public-api.ts index 3760e4c..2ee6c91 100644 --- a/projects/s-ng-utils/src/public-api.ts +++ b/projects/s-ng-utils/src/public-api.ts @@ -2,12 +2,12 @@ * Public API Surface of s-ng-utils */ -export { AutoDestroyable } from "./lib/auto-destroyable"; export { DirectiveSuperclass } from "./lib/directive-superclass"; export { FormControlSuperclass, provideValueAccessor, } from "./lib/form-control-superclass"; +export { InjectableSuperclass } from "./lib/injectable-superclass"; export { WrappedFormControlSuperclass, } from "./lib/wrapped-form-control-superclass"; diff --git a/src/app/app.component.ts b/src/app/app.component.ts index b0ab97e..1c80423 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,9 +1,9 @@ import { Component, Injector } from "@angular/core"; import { FormControl, Validators } from "@angular/forms"; import { - AutoDestroyable, DirectiveSuperclass, FormControlSuperclass, + InjectableSuperclass, provideValueAccessor, WrappedFormControlSuperclass, } from "s-ng-utils"; @@ -23,8 +23,8 @@ export class AppComponent { constructor(injector: Injector) { // use each function once just to show in can be imported // tslint:disable:no-unused-expression - new (class extends AutoDestroyable {})(); new (class extends DirectiveSuperclass {})(injector); + new (class extends InjectableSuperclass {})(); provideValueAccessor(AppComponent); new (class extends FormControlSuperclass { handleIncomingValue() {}