Socket
Socket
Sign inDemoInstall

angular2-take-until-destroy

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular2-take-until-destroy - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

12

dist/angular2-take-until-destroy.js
import { Subject } from "rxjs";
export function TakeUntilDestroy(constructor) {
var original = constructor.prototype.ngOnDestroy;
var subject = new Subject();
var originalDestroy = constructor.prototype.ngOnDestroy;
constructor.prototype.componentDestroy = function () {
return subject.asObservable();
this._takeUntilDestroy$ = this._takeUntilDestroy$ || new Subject();
return this._takeUntilDestroy$.asObservable();
};
constructor.prototype.ngOnDestroy = function () {
original && typeof original === 'function' && original.apply(this, arguments);
subject.next('ngOnDestroy');
subject.unsubscribe();
subject = new Subject();
originalDestroy && typeof originalDestroy === 'function' && originalDestroy.apply(this, arguments);
this._takeUntilDestroy$ && this._takeUntilDestroy$.complete();
};
}
//# sourceMappingURL=angular2-take-until-destroy.js.map
{
"name": "angular2-take-until-destroy",
"version": "1.0.3",
"version": "1.0.4",
"main": "dist/index.js",

@@ -8,3 +8,10 @@ "description": "Add take until component destroy for easy unsubscribe when the component destroyed",

"scripts": {
"prepublish": "rm -rf ./dist && tsc"
"clearDist": "rm -rf ./dist",
"clearTest": "rm -rf ./dist-test",
"clear": "npm run clearDist && npm run clearTest",
"compile": "tsc",
"precompile": "npm run clearDist",
"compileTest": "tsc -p tsconfig-test.json",
"prepublish": "clear && npm run compile",
"test": "npm run clear && npm run compile && npm run compileTest && tape ./dist-test/test/index.js"
},

@@ -16,3 +23,4 @@ "typings": "./dist/index.d.ts",

"maintainers": [
"Netanel Basal"
"Netanel Basal",
"Eduard Fidiles"
],

@@ -25,4 +33,5 @@ "repository": {

"rxjs": "^5.0.0-rc.1",
"tape": "^4.8.0",
"typescript": "^2.0.6"
}
}

@@ -18,8 +18,12 @@ # Angular 2 - easy unsubscribe when component destroyed

export class InboxComponent {
componentDestroy;
constructor( ) {
const timer$ = Observable.interval(1000)
.takeUntil((<any>this).componentDestroy())
.takeUntil(this.componentDestroy())
.subscribe(val => console.log(val))
}
// If you work with AOT this method must be present, even if empty!
// Otherwise 'ng build --prod' will optimize away any calls to ngOnDestroy,
// even if the method is added by the @TakeUntilDestroy decorator
ngOnDestroy() {

@@ -26,0 +30,0 @@ // You can also do whatever you need here

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc