@badisi/ngx-safe-subscribe 2.2.5 → 2.2.8
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,8 +3,8 @@
|
|
|
3
3
|
Automatically unsubscribe from RxJS observables in Angular components.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@badisi/ngx-safe-subscribe)
|
|
6
|
-
[](https://github.com/Badisi/ngx-safe-subscribe/blob/
|
|
6
|
+
[](https://npmcharts.com/compare/@badisi/ngx-safe-subscribe?minimal=true)
|
|
7
|
+
[](https://github.com/Badisi/ngx-safe-subscribe/blob/main/LICENSE)
|
|
8
8
|
|
|
9
9
|
<!--[](https://david-dm.org/badisi/ngx-safe-subscribe?type=peer)-->
|
|
10
10
|
|
|
@@ -14,11 +14,11 @@ Automatically unsubscribe from RxJS observables in Angular components.
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
16
|
```sh
|
|
17
|
-
|
|
17
|
+
npm install @badisi/ngx-safe-subscribe --save
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
```sh
|
|
21
|
-
|
|
21
|
+
yarn add @badisi/ngx-safe-subscribe
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## Usage
|
|
@@ -1 +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":";;
|
|
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":";;AAaM,SAAU,aAAa,CACzB,MAAwB,EACxB,IAAyB,EACzB,KAA4B,EAC5B,QAAqB,EAAA;AAErB,IAAA,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AAClD,IAAA,IAAI,MAAM,EAAE;AACR,QAAA,IAAI,EAAE,iCAAiC,IAAI,MAAM,CAAC,EAAE;AAChD,YAAA,MAAM,CAAC,+BAA+B,GAAG,IAAI,YAAY,EAAE,CAAC;AAE5D,YAAA,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CAAC;YAC3C,IAAI,CAAC,eAAe,EAAE;gBAClB,OAAO,CAAC,IAAI,CAAC,CAAI,EAAA,MAAc,CAAC,WAAW,CAAC,IAAI,CAAsF,oFAAA,CAAA,CAAC,CAAC;AAC3I,aAAA;YACD,MAAM,CAAC,WAAW,GAAG,YAAA;gBACjB,IAAI,eAAe,KAAK,OAAO,eAAe,KAAK,UAAU,CAAC,EAAE;AAC5D,oBAAA,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAC1C,iBAAA;AACD,gBAAA,MAAM,CAAC,+BAA+B,CAAC,WAAW,EAAE,CAAC;AACzD,aAAC,CAAC;AACL,SAAA;AACD,QAAA,MAAM,CAAC,+BAA+B,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACnD,KAAA;AACD,IAAA,OAAO,GAAG,CAAC;AACf,CAAC;AACD,UAAU,CAAC,SAAS,CAAC,aAAa,GAAG,aAAa;;ACvClD;;AAEG;;;;"}
|
|
@@ -1 +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":";;
|
|
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":";;AAaM,SAAU,aAAa,CACzB,MAAwB,EACxB,IAAyB,EACzB,KAA4B,EAC5B,QAAqB,EAAA;AAErB,IAAA,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AAClD,IAAA,IAAI,MAAM,EAAE;AACR,QAAA,IAAI,EAAE,iCAAiC,IAAI,MAAM,CAAC,EAAE;AAChD,YAAA,MAAM,CAAC,+BAA+B,GAAG,IAAI,YAAY,EAAE,CAAC;AAE5D,YAAA,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CAAC;YAC3C,IAAI,CAAC,eAAe,EAAE;gBAClB,OAAO,CAAC,IAAI,CAAC,CAAI,EAAA,MAAc,CAAC,WAAW,CAAC,IAAI,CAAsF,oFAAA,CAAA,CAAC,CAAC;AAC3I,aAAA;YACD,MAAM,CAAC,WAAW,GAAG,YAAA;gBACjB,IAAI,eAAe,KAAK,OAAO,eAAe,KAAK,UAAU,CAAC,EAAE;AAC5D,oBAAA,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAC1C,iBAAA;AACD,gBAAA,MAAM,CAAC,+BAA+B,CAAC,WAAW,EAAE,CAAC;AACzD,aAAC,CAAC;AACL,SAAA;AACD,QAAA,MAAM,CAAC,+BAA+B,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACnD,KAAA;AACD,IAAA,OAAO,GAAG,CAAC;AACf,CAAC;AACD,UAAU,CAAC,SAAS,CAAC,aAAa,GAAG,aAAa;;ACvClD;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@badisi/ngx-safe-subscribe",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.8",
|
|
4
4
|
"description": "Easy way to automatically unsubscribe from RxJS observables in Angular components",
|
|
5
5
|
"homepage": "https://github.com/badisi/ngx-safe-subscribe",
|
|
6
6
|
"license": "MIT",
|