Skip to content

Commit

Permalink
Merge pull request #20 from cloudnc/fix/bad-call-to-missing-ngondestroy
Browse files Browse the repository at this point in the history
  • Loading branch information
zak-cloudnc authored Feb 24, 2021
2 parents 9f3d2d9 + e07b59a commit 16ef260
Show file tree
Hide file tree
Showing 7 changed files with 2,097 additions and 1,574 deletions.
3 changes: 1 addition & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
Expand Down Expand Up @@ -103,7 +102,7 @@
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"tsConfig": "projects/ngx-observable-lifecycle/tsconfig.lib.json",
"project": "projects/ngx-observable-lifecycle/ng-package.json"
Expand Down
35 changes: 17 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,39 +33,38 @@
"commit": "git add . && git-cz"
},
"dependencies": {
"@angular/animations": "~10.2.0",
"@angular/common": "~10.2.0",
"@angular/compiler": "~10.2.0",
"@angular/core": "~10.2.0",
"@angular/forms": "~10.2.0",
"@angular/platform-browser": "~10.2.0",
"@angular/platform-browser-dynamic": "~10.2.0",
"@angular/router": "~10.2.0",
"@angular/animations": "~11.2.3",
"@angular/common": "~11.2.3",
"@angular/compiler": "~11.2.3",
"@angular/core": "~11.2.3",
"@angular/forms": "~11.2.3",
"@angular/platform-browser": "~11.2.3",
"@angular/platform-browser-dynamic": "~11.2.3",
"@angular/router": "~11.2.3",
"rxjs": "~6.5.4",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1001.7",
"@angular-devkit/build-ng-packagr": "~0.1001.7",
"@angular/cli": "~10.1.7",
"@angular/compiler-cli": "~10.2.0",
"@angular/language-service": "~10.2.0",
"@types/jasmine": "~3.5.0",
"@angular-devkit/build-angular": "~0.1102.1",
"@angular/cli": "~11.2.1",
"@angular/compiler-cli": "~11.2.3",
"@angular/language-service": "~11.2.3",
"@types/jasmine": "~3.6.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"codecov": "^3.7.0",
"codelyzer": "^5.1.2",
"codelyzer": "^6.0.0",
"commitizen": "4.1.2",
"embedme": "1.21.0",
"jasmine-core": "~3.5.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma": "~6.1.1",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"ng-packagr": "^10.1.0",
"ng-packagr": "^11.2.4",
"prettier": "2.0.5",
"protractor": "~7.0.0",
"semantic-release": "^17.2.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,27 @@ describe('ngx-observable-lifecycle', () => {

(instance as OnDestroy).ngOnDestroy();
});

it('should not throw if onDestroy was invoked on difference instances', () => {
const originalOnDestroySpy = jasmine.createSpy();

class TestClass implements OnDestroy {
public ngOnDestroy(): void {
originalOnDestroySpy();
}
}

const instance = new TestClass();
const instance2 = new TestClass();

const { ngOnDestroy } = getObservableLifecycle(instance);

expect(originalOnDestroySpy).not.toHaveBeenCalled();

instance.ngOnDestroy();
instance2.ngOnDestroy();

expect(originalOnDestroySpy).toHaveBeenCalled();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function getSubjectForHook(componentInstance: PatchedComponentInstance<any>, hoo

proto[hook] = function (this: PatchedComponentInstance<typeof hook>) {
(originalHook as () => void)?.call(this);
this[hookSubject][hook].next();
this[hookSubject]?.[hook]?.next();
};

const originalOnDestroy = proto.ngOnDestroy;
Expand Down
1 change: 1 addition & 0 deletions projects/ngx-observable-lifecycle/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"declarationMap": true,
"target": "es2015",
"declaration": true,
"inlineSources": true,
Expand Down
3 changes: 3 additions & 0 deletions projects/ngx-observable-lifecycle/tsconfig.lib.prod.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"declarationMap": false
},
"angularCompilerOptions": {
"enableIvy": false
}
Expand Down
Loading

0 comments on commit 16ef260

Please sign in to comment.