Skip to content

Commit 16ef260

Browse files
authored
Merge pull request #20 from cloudnc/fix/bad-call-to-missing-ngondestroy
2 parents 9f3d2d9 + e07b59a commit 16ef260

File tree

7 files changed

+2097
-1574
lines changed

7 files changed

+2097
-1574
lines changed

angular.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"optimization": true,
3939
"outputHashing": "all",
4040
"sourceMap": false,
41-
"extractCss": true,
4241
"namedChunks": false,
4342
"extractLicenses": true,
4443
"vendorChunk": false,
@@ -103,7 +102,7 @@
103102
"prefix": "lib",
104103
"architect": {
105104
"build": {
106-
"builder": "@angular-devkit/build-ng-packagr:build",
105+
"builder": "@angular-devkit/build-angular:ng-packagr",
107106
"options": {
108107
"tsConfig": "projects/ngx-observable-lifecycle/tsconfig.lib.json",
109108
"project": "projects/ngx-observable-lifecycle/ng-package.json"

package.json

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,39 +33,38 @@
3333
"commit": "git add . && git-cz"
3434
},
3535
"dependencies": {
36-
"@angular/animations": "~10.2.0",
37-
"@angular/common": "~10.2.0",
38-
"@angular/compiler": "~10.2.0",
39-
"@angular/core": "~10.2.0",
40-
"@angular/forms": "~10.2.0",
41-
"@angular/platform-browser": "~10.2.0",
42-
"@angular/platform-browser-dynamic": "~10.2.0",
43-
"@angular/router": "~10.2.0",
36+
"@angular/animations": "~11.2.3",
37+
"@angular/common": "~11.2.3",
38+
"@angular/compiler": "~11.2.3",
39+
"@angular/core": "~11.2.3",
40+
"@angular/forms": "~11.2.3",
41+
"@angular/platform-browser": "~11.2.3",
42+
"@angular/platform-browser-dynamic": "~11.2.3",
43+
"@angular/router": "~11.2.3",
4444
"rxjs": "~6.5.4",
4545
"tslib": "^2.0.0",
4646
"zone.js": "~0.10.2"
4747
},
4848
"devDependencies": {
49-
"@angular-devkit/build-angular": "~0.1001.7",
50-
"@angular-devkit/build-ng-packagr": "~0.1001.7",
51-
"@angular/cli": "~10.1.7",
52-
"@angular/compiler-cli": "~10.2.0",
53-
"@angular/language-service": "~10.2.0",
54-
"@types/jasmine": "~3.5.0",
49+
"@angular-devkit/build-angular": "~0.1102.1",
50+
"@angular/cli": "~11.2.1",
51+
"@angular/compiler-cli": "~11.2.3",
52+
"@angular/language-service": "~11.2.3",
53+
"@types/jasmine": "~3.6.0",
5554
"@types/jasminewd2": "~2.0.3",
5655
"@types/node": "^12.11.1",
5756
"codecov": "^3.7.0",
58-
"codelyzer": "^5.1.2",
57+
"codelyzer": "^6.0.0",
5958
"commitizen": "4.1.2",
6059
"embedme": "1.21.0",
61-
"jasmine-core": "~3.5.0",
60+
"jasmine-core": "~3.6.0",
6261
"jasmine-spec-reporter": "~5.0.0",
63-
"karma": "~5.0.0",
62+
"karma": "~6.1.1",
6463
"karma-chrome-launcher": "~3.1.0",
6564
"karma-coverage-istanbul-reporter": "~3.0.2",
6665
"karma-jasmine": "~4.0.0",
6766
"karma-jasmine-html-reporter": "^1.5.0",
68-
"ng-packagr": "^10.1.0",
67+
"ng-packagr": "^11.2.4",
6968
"prettier": "2.0.5",
7069
"protractor": "~7.0.0",
7170
"semantic-release": "^17.2.3",

projects/ngx-observable-lifecycle/src/lib/ngx-observable-lifecycle.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,27 @@ describe('ngx-observable-lifecycle', () => {
8484

8585
(instance as OnDestroy).ngOnDestroy();
8686
});
87+
88+
it('should not throw if onDestroy was invoked on difference instances', () => {
89+
const originalOnDestroySpy = jasmine.createSpy();
90+
91+
class TestClass implements OnDestroy {
92+
public ngOnDestroy(): void {
93+
originalOnDestroySpy();
94+
}
95+
}
96+
97+
const instance = new TestClass();
98+
const instance2 = new TestClass();
99+
100+
const { ngOnDestroy } = getObservableLifecycle(instance);
101+
102+
expect(originalOnDestroySpy).not.toHaveBeenCalled();
103+
104+
instance.ngOnDestroy();
105+
instance2.ngOnDestroy();
106+
107+
expect(originalOnDestroySpy).toHaveBeenCalled();
108+
});
87109
});
88110
});

projects/ngx-observable-lifecycle/src/lib/ngx-observable-lifecycle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function getSubjectForHook(componentInstance: PatchedComponentInstance<any>, hoo
5757

5858
proto[hook] = function (this: PatchedComponentInstance<typeof hook>) {
5959
(originalHook as () => void)?.call(this);
60-
this[hookSubject][hook].next();
60+
this[hookSubject]?.[hook]?.next();
6161
};
6262

6363
const originalOnDestroy = proto.ngOnDestroy;

projects/ngx-observable-lifecycle/tsconfig.lib.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"outDir": "../../out-tsc/lib",
5+
"declarationMap": true,
56
"target": "es2015",
67
"declaration": true,
78
"inlineSources": true,

projects/ngx-observable-lifecycle/tsconfig.lib.prod.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"extends": "./tsconfig.lib.json",
3+
"compilerOptions": {
4+
"declarationMap": false
5+
},
36
"angularCompilerOptions": {
47
"enableIvy": false
58
}

0 commit comments

Comments
 (0)