SHARE
TWEET

Untitled

a guest Dec 9th, 2018 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export function autoClearSubscriptions(constructor: Function) {
  2.   return class extends constructor {
  3.     ngOnDestroy() {
  4.       console.log('Cleaning....')
  5.       // Auto Clean things
  6.       if(constructor.prototype.subscriptions) {
  7.         return;
  8.       }
  9.       constructor.prototype.subscriptions.length = 0;
  10.       // call the original method
  11.       constructor.prototype.ngOnDestroy.apply(this, arguments);
  12.     }
  13.   }
  14. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top