Guest User

Untitled

a guest
Jan 13th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. export function AutoUnsubscribe( constructor ) {
  2.  
  3. const original = constructor.prototype.ngOnDestroy;
  4.  
  5. constructor.prototype.ngOnDestroy = function () {
  6. for ( let prop in this ) {
  7. const property = this[ prop ];
  8. if ( property && (typeof property.unsubscribe === "function") ) {
  9. property.unsubscribe();
  10. }
  11. }
  12. original && typeof original === "function" && original.apply(this, arguments);
  13. };
  14.  
  15. }
Add Comment
Please, Sign In to add comment