@badisi/ngx-safe-subscribe 2.2.2 → 2.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,10 +3,10 @@
3
3
  Automatically unsubscribe from RxJS observables in Angular components.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@badisi/ngx-safe-subscribe?color=blue&logo=npm)](https://www.npmjs.com/package/@badisi/ngx-safe-subscribe)
6
- [![Download](https://img.shields.io/npm/dw/@badisi/ngx-safe-subscribe.svg?color=blue&logo=npm)](https://npmcharts.com/compare/@badisi/ngx-safe-subscribe?minimal=true)
6
+ [![Download](https://img.shields.io/npm/dw/@badisi/ngx-safe-subscribe.svg?color=7986CB&logo=npm)](https://npmcharts.com/compare/@badisi/ngx-safe-subscribe?minimal=true)
7
7
  [![License](https://img.shields.io/npm/l/@badisi/ngx-safe-subscribe.svg?color=ff69b4)](https://github.com/Badisi/ngx-safe-subscribe/blob/master/LICENSE)
8
8
 
9
- [![peerDependency Status](https://david-dm.org/badisi/ngx-safe-subscribe/peer-status.svg)](https://david-dm.org/badisi/ngx-safe-subscribe?type=peer)
9
+ <!--[![peerDependency Status](https://david-dm.org/badisi/ngx-safe-subscribe/peer-status.svg)](https://david-dm.org/badisi/ngx-safe-subscribe?type=peer)-->
10
10
 
11
11
  :zap: *RxJS 5+ version available [here](https://github.com/Badisi/ngx-safe-subscribe/tree/rxjs-5x)*
12
12
 
@@ -14,11 +14,11 @@ Automatically unsubscribe from RxJS observables in Angular components.
14
14
  ## Installation
15
15
 
16
16
  ```sh
17
- $ npm install @badisi/ngx-safe-subscribe --save
17
+ npm install @badisi/ngx-safe-subscribe --save
18
18
  ```
19
19
 
20
20
  ```sh
21
- $ yarn add @badisi/ngx-safe-subscribe
21
+ yarn add @badisi/ngx-safe-subscribe
22
22
  ```
23
23
 
24
24
  ## Usage
@@ -1,4 +1,5 @@
1
1
  /**
2
2
  * Generated bundle index. Do not edit.
3
3
  */
4
+ /// <amd-module name="@badisi/ngx-safe-subscribe" />
4
5
  export * from './ngx-safe-subscribe';
@@ -27,4 +27,4 @@ Observable.prototype.safeSubscribe = safeSubscribe;
27
27
  */
28
28
 
29
29
  export { safeSubscribe };
30
- //# sourceMappingURL=badisi-ngx-safe-subscribe.js.map
30
+ //# sourceMappingURL=badisi-ngx-safe-subscribe.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"badisi-ngx-safe-subscribe.mjs","sources":["../../ngx-safe-subscribe.ts","../../badisi-ngx-safe-subscribe.ts"],"sourcesContent":["import { Observable, Subscription } from 'rxjs';\n\ndeclare module 'rxjs/internal/Observable' {\n interface Observable<T> {\n safeSubscribe: typeof safeSubscribe;\n }\n}\n\nexport interface SafeSubscribable {\n _subscriptionFromSafeSubscribe$?: Subscription;\n ngOnDestroy(): void;\n}\n\nexport function safeSubscribe<T>(\n target: SafeSubscribable,\n next?: (value: T) => void,\n error?: (error: any) => void,\n complete?: () => void\n): Subscription {\n const sub = this.subscribe(next, error, complete);\n if (target) {\n if (!('_subscriptionFromSafeSubscribe$' in target)) {\n target._subscriptionFromSafeSubscribe$ = new Subscription();\n\n const originalDestroy = target.ngOnDestroy;\n if (!originalDestroy) {\n console.warn(`${(target as any).constructor.name} must implement OnDestroy otherwise Observable<T>.safeSubscribe will have no effect.`);\n }\n target.ngOnDestroy = function () {\n if (originalDestroy && (typeof originalDestroy === 'function')) {\n originalDestroy.apply(this, arguments);\n }\n target._subscriptionFromSafeSubscribe$.unsubscribe();\n };\n }\n target._subscriptionFromSafeSubscribe$.add(sub);\n }\n return sub;\n}\nObservable.prototype.safeSubscribe = safeSubscribe;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './ngx-safe-subscribe';\n"],"names":[],"mappings":";;SAagB,aAAa,CACzB,MAAwB,EACxB,IAAyB,EACzB,KAA4B,EAC5B,QAAqB;IAErB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAClD,IAAI,MAAM,EAAE;QACR,IAAI,EAAE,iCAAiC,IAAI,MAAM,CAAC,EAAE;YAChD,MAAM,CAAC,+BAA+B,GAAG,IAAI,YAAY,EAAE,CAAC;YAE5D,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CAAC;YAC3C,IAAI,CAAC,eAAe,EAAE;gBAClB,OAAO,CAAC,IAAI,CAAC,GAAI,MAAc,CAAC,WAAW,CAAC,IAAI,sFAAsF,CAAC,CAAC;aAC3I;YACD,MAAM,CAAC,WAAW,GAAG;gBACjB,IAAI,eAAe,KAAK,OAAO,eAAe,KAAK,UAAU,CAAC,EAAE;oBAC5D,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;iBAC1C;gBACD,MAAM,CAAC,+BAA+B,CAAC,WAAW,EAAE,CAAC;aACxD,CAAC;SACL;QACD,MAAM,CAAC,+BAA+B,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KACnD;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AACD,UAAU,CAAC,SAAS,CAAC,aAAa,GAAG,aAAa;;ACvClD;;;;;;"}
@@ -0,0 +1,30 @@
1
+ import { Subscription, Observable } from 'rxjs';
2
+
3
+ function safeSubscribe(target, next, error, complete) {
4
+ const sub = this.subscribe(next, error, complete);
5
+ if (target) {
6
+ if (!('_subscriptionFromSafeSubscribe$' in target)) {
7
+ target._subscriptionFromSafeSubscribe$ = new Subscription();
8
+ const originalDestroy = target.ngOnDestroy;
9
+ if (!originalDestroy) {
10
+ console.warn(`${target.constructor.name} must implement OnDestroy otherwise Observable<T>.safeSubscribe will have no effect.`);
11
+ }
12
+ target.ngOnDestroy = function () {
13
+ if (originalDestroy && (typeof originalDestroy === 'function')) {
14
+ originalDestroy.apply(this, arguments);
15
+ }
16
+ target._subscriptionFromSafeSubscribe$.unsubscribe();
17
+ };
18
+ }
19
+ target._subscriptionFromSafeSubscribe$.add(sub);
20
+ }
21
+ return sub;
22
+ }
23
+ Observable.prototype.safeSubscribe = safeSubscribe;
24
+
25
+ /**
26
+ * Generated bundle index. Do not edit.
27
+ */
28
+
29
+ export { safeSubscribe };
30
+ //# sourceMappingURL=badisi-ngx-safe-subscribe.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"badisi-ngx-safe-subscribe.mjs","sources":["../../ngx-safe-subscribe.ts","../../badisi-ngx-safe-subscribe.ts"],"sourcesContent":["import { Observable, Subscription } from 'rxjs';\n\ndeclare module 'rxjs/internal/Observable' {\n interface Observable<T> {\n safeSubscribe: typeof safeSubscribe;\n }\n}\n\nexport interface SafeSubscribable {\n _subscriptionFromSafeSubscribe$?: Subscription;\n ngOnDestroy(): void;\n}\n\nexport function safeSubscribe<T>(\n target: SafeSubscribable,\n next?: (value: T) => void,\n error?: (error: any) => void,\n complete?: () => void\n): Subscription {\n const sub = this.subscribe(next, error, complete);\n if (target) {\n if (!('_subscriptionFromSafeSubscribe$' in target)) {\n target._subscriptionFromSafeSubscribe$ = new Subscription();\n\n const originalDestroy = target.ngOnDestroy;\n if (!originalDestroy) {\n console.warn(`${(target as any).constructor.name} must implement OnDestroy otherwise Observable<T>.safeSubscribe will have no effect.`);\n }\n target.ngOnDestroy = function () {\n if (originalDestroy && (typeof originalDestroy === 'function')) {\n originalDestroy.apply(this, arguments);\n }\n target._subscriptionFromSafeSubscribe$.unsubscribe();\n };\n }\n target._subscriptionFromSafeSubscribe$.add(sub);\n }\n return sub;\n}\nObservable.prototype.safeSubscribe = safeSubscribe;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './ngx-safe-subscribe';\n"],"names":[],"mappings":";;SAagB,aAAa,CACzB,MAAwB,EACxB,IAAyB,EACzB,KAA4B,EAC5B,QAAqB;IAErB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAClD,IAAI,MAAM,EAAE;QACR,IAAI,EAAE,iCAAiC,IAAI,MAAM,CAAC,EAAE;YAChD,MAAM,CAAC,+BAA+B,GAAG,IAAI,YAAY,EAAE,CAAC;YAE5D,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CAAC;YAC3C,IAAI,CAAC,eAAe,EAAE;gBAClB,OAAO,CAAC,IAAI,CAAC,GAAI,MAAc,CAAC,WAAW,CAAC,IAAI,sFAAsF,CAAC,CAAC;aAC3I;YACD,MAAM,CAAC,WAAW,GAAG;gBACjB,IAAI,eAAe,KAAK,OAAO,eAAe,KAAK,UAAU,CAAC,EAAE;oBAC5D,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;iBAC1C;gBACD,MAAM,CAAC,+BAA+B,CAAC,WAAW,EAAE,CAAC;aACxD,CAAC;SACL;QACD,MAAM,CAAC,+BAA+B,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KACnD;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AACD,UAAU,CAAC,SAAS,CAAC,aAAa,GAAG,aAAa;;ACvClD;;;;;;"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@badisi/ngx-safe-subscribe",
3
- "version": "2.2.2",
3
+ "version": "2.2.6",
4
4
  "description": "Easy way to automatically unsubscribe from RxJS observables in Angular components",
5
- "homepage": "https://github.com/Badisi/ngx-safe-subscribe",
5
+ "homepage": "https://github.com/badisi/ngx-safe-subscribe",
6
6
  "license": "MIT",
7
7
  "sideEffects": true,
8
8
  "author": {
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "https://github.com/Badisi/ngx-safe-subscribe.git"
13
+ "url": "https://github.com/badisi/ngx-safe-subscribe.git"
14
14
  },
15
15
  "keywords": [
16
16
  "angular",
@@ -26,14 +26,26 @@
26
26
  "@angular/core": ">=6.0.0",
27
27
  "rxjs": ">=6.0.0"
28
28
  },
29
- "main": "bundles/badisi-ngx-safe-subscribe.umd.js",
30
- "module": "fesm2015/badisi-ngx-safe-subscribe.js",
31
- "es2015": "fesm2015/badisi-ngx-safe-subscribe.js",
32
- "esm2015": "esm2015/badisi-ngx-safe-subscribe.js",
33
- "fesm2015": "fesm2015/badisi-ngx-safe-subscribe.js",
29
+ "module": "fesm2015/badisi-ngx-safe-subscribe.mjs",
30
+ "es2020": "fesm2020/badisi-ngx-safe-subscribe.mjs",
31
+ "esm2020": "esm2020/badisi-ngx-safe-subscribe.mjs",
32
+ "fesm2020": "fesm2020/badisi-ngx-safe-subscribe.mjs",
33
+ "fesm2015": "fesm2015/badisi-ngx-safe-subscribe.mjs",
34
34
  "typings": "badisi-ngx-safe-subscribe.d.ts",
35
- "metadata": "badisi-ngx-safe-subscribe.metadata.json",
35
+ "exports": {
36
+ "./package.json": {
37
+ "default": "./package.json"
38
+ },
39
+ ".": {
40
+ "types": "./badisi-ngx-safe-subscribe.d.ts",
41
+ "esm2020": "./esm2020/badisi-ngx-safe-subscribe.mjs",
42
+ "es2020": "./fesm2020/badisi-ngx-safe-subscribe.mjs",
43
+ "es2015": "./fesm2015/badisi-ngx-safe-subscribe.mjs",
44
+ "node": "./fesm2015/badisi-ngx-safe-subscribe.mjs",
45
+ "default": "./fesm2020/badisi-ngx-safe-subscribe.mjs"
46
+ }
47
+ },
36
48
  "dependencies": {
37
- "tslib": "^2.1.0"
49
+ "tslib": "^2.3.0"
38
50
  }
39
51
  }
@@ -1 +0,0 @@
1
- {"__symbolic":"module","version":4,"metadata":{"SafeSubscribable":{"__symbolic":"interface"},"safeSubscribe":{"__symbolic":"function"}},"origins":{"SafeSubscribable":"./ngx-safe-subscribe","safeSubscribe":"./ngx-safe-subscribe"},"importAs":"@badisi/ngx-safe-subscribe"}
@@ -1,38 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs')) :
3
- typeof define === 'function' && define.amd ? define('@badisi/ngx-safe-subscribe', ['exports', 'rxjs'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.badisi = global.badisi || {}, global.badisi['ngx-safe-subscribe'] = {}), global.rxjs));
5
- }(this, (function (exports, rxjs) { 'use strict';
6
-
7
- function safeSubscribe(target, next, error, complete) {
8
- var sub = this.subscribe(next, error, complete);
9
- if (target) {
10
- if (!('_subscriptionFromSafeSubscribe$' in target)) {
11
- target._subscriptionFromSafeSubscribe$ = new rxjs.Subscription();
12
- var originalDestroy_1 = target.ngOnDestroy;
13
- if (!originalDestroy_1) {
14
- console.warn(target.constructor.name + " must implement OnDestroy otherwise Observable<T>.safeSubscribe will have no effect.");
15
- }
16
- target.ngOnDestroy = function () {
17
- if (originalDestroy_1 && (typeof originalDestroy_1 === 'function')) {
18
- originalDestroy_1.apply(this, arguments);
19
- }
20
- target._subscriptionFromSafeSubscribe$.unsubscribe();
21
- };
22
- }
23
- target._subscriptionFromSafeSubscribe$.add(sub);
24
- }
25
- return sub;
26
- }
27
- rxjs.Observable.prototype.safeSubscribe = safeSubscribe;
28
-
29
- /**
30
- * Generated bundle index. Do not edit.
31
- */
32
-
33
- exports.safeSubscribe = safeSubscribe;
34
-
35
- Object.defineProperty(exports, '__esModule', { value: true });
36
-
37
- })));
38
- //# sourceMappingURL=badisi-ngx-safe-subscribe.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"badisi-ngx-safe-subscribe.umd.js","sources":["../../ngx-safe-subscribe.ts","../../badisi-ngx-safe-subscribe.ts"],"sourcesContent":["import { Observable, Subscription } from 'rxjs';\n\ndeclare module 'rxjs/internal/Observable' {\n interface Observable<T> {\n safeSubscribe: typeof safeSubscribe;\n }\n}\n\nexport interface SafeSubscribable {\n _subscriptionFromSafeSubscribe$?: Subscription;\n ngOnDestroy(): void;\n}\n\nexport function safeSubscribe<T>(\n target: SafeSubscribable,\n next?: (value: T) => void,\n error?: (error: any) => void,\n complete?: () => void\n): Subscription {\n const sub = this.subscribe(next, error, complete);\n if (target) {\n if (!('_subscriptionFromSafeSubscribe$' in target)) {\n target._subscriptionFromSafeSubscribe$ = new Subscription();\n\n const originalDestroy = target.ngOnDestroy;\n if (!originalDestroy) {\n console.warn(`${(target as any).constructor.name} must implement OnDestroy otherwise Observable<T>.safeSubscribe will have no effect.`);\n }\n target.ngOnDestroy = function () {\n if (originalDestroy && (typeof originalDestroy === 'function')) {\n originalDestroy.apply(this, arguments);\n }\n target._subscriptionFromSafeSubscribe$.unsubscribe();\n };\n }\n target._subscriptionFromSafeSubscribe$.add(sub);\n }\n return sub;\n}\nObservable.prototype.safeSubscribe = safeSubscribe;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './ngx-safe-subscribe';\n"],"names":["Subscription","Observable"],"mappings":";;;;;;aAagB,aAAa,CACzB,MAAwB,EACxB,IAAyB,EACzB,KAA4B,EAC5B,QAAqB;QAErB,IAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAClD,IAAI,MAAM,EAAE;YACR,IAAI,EAAE,iCAAiC,IAAI,MAAM,CAAC,EAAE;gBAChD,MAAM,CAAC,+BAA+B,GAAG,IAAIA,iBAAY,EAAE,CAAC;gBAE5D,IAAM,iBAAe,GAAG,MAAM,CAAC,WAAW,CAAC;gBAC3C,IAAI,CAAC,iBAAe,EAAE;oBAClB,OAAO,CAAC,IAAI,CAAK,MAAc,CAAC,WAAW,CAAC,IAAI,yFAAsF,CAAC,CAAC;iBAC3I;gBACD,MAAM,CAAC,WAAW,GAAG;oBACjB,IAAI,iBAAe,KAAK,OAAO,iBAAe,KAAK,UAAU,CAAC,EAAE;wBAC5D,iBAAe,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;qBAC1C;oBACD,MAAM,CAAC,+BAA+B,CAAC,WAAW,EAAE,CAAC;iBACxD,CAAC;aACL;YACD,MAAM,CAAC,+BAA+B,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SACnD;QACD,OAAO,GAAG,CAAC;IACf,CAAC;AACDC,mBAAU,CAAC,SAAS,CAAC,aAAa,GAAG,aAAa;;ICvClD;;;;;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"badisi-ngx-safe-subscribe.js","sources":["../../ngx-safe-subscribe.ts","../../badisi-ngx-safe-subscribe.ts"],"sourcesContent":["import { Observable, Subscription } from 'rxjs';\n\ndeclare module 'rxjs/internal/Observable' {\n interface Observable<T> {\n safeSubscribe: typeof safeSubscribe;\n }\n}\n\nexport interface SafeSubscribable {\n _subscriptionFromSafeSubscribe$?: Subscription;\n ngOnDestroy(): void;\n}\n\nexport function safeSubscribe<T>(\n target: SafeSubscribable,\n next?: (value: T) => void,\n error?: (error: any) => void,\n complete?: () => void\n): Subscription {\n const sub = this.subscribe(next, error, complete);\n if (target) {\n if (!('_subscriptionFromSafeSubscribe$' in target)) {\n target._subscriptionFromSafeSubscribe$ = new Subscription();\n\n const originalDestroy = target.ngOnDestroy;\n if (!originalDestroy) {\n console.warn(`${(target as any).constructor.name} must implement OnDestroy otherwise Observable<T>.safeSubscribe will have no effect.`);\n }\n target.ngOnDestroy = function () {\n if (originalDestroy && (typeof originalDestroy === 'function')) {\n originalDestroy.apply(this, arguments);\n }\n target._subscriptionFromSafeSubscribe$.unsubscribe();\n };\n }\n target._subscriptionFromSafeSubscribe$.add(sub);\n }\n return sub;\n}\nObservable.prototype.safeSubscribe = safeSubscribe;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './ngx-safe-subscribe';\n"],"names":[],"mappings":";;SAagB,aAAa,CACzB,MAAwB,EACxB,IAAyB,EACzB,KAA4B,EAC5B,QAAqB;IAErB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAClD,IAAI,MAAM,EAAE;QACR,IAAI,EAAE,iCAAiC,IAAI,MAAM,CAAC,EAAE;YAChD,MAAM,CAAC,+BAA+B,GAAG,IAAI,YAAY,EAAE,CAAC;YAE5D,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CAAC;YAC3C,IAAI,CAAC,eAAe,EAAE;gBAClB,OAAO,CAAC,IAAI,CAAC,GAAI,MAAc,CAAC,WAAW,CAAC,IAAI,sFAAsF,CAAC,CAAC;aAC3I;YACD,MAAM,CAAC,WAAW,GAAG;gBACjB,IAAI,eAAe,KAAK,OAAO,eAAe,KAAK,UAAU,CAAC,EAAE;oBAC5D,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;iBAC1C;gBACD,MAAM,CAAC,+BAA+B,CAAC,WAAW,EAAE,CAAC;aACxD,CAAC;SACL;QACD,MAAM,CAAC,+BAA+B,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KACnD;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AACD,UAAU,CAAC,SAAS,CAAC,aAAa,GAAG,aAAa;;ACvClD;;;;;;"}