Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export function DestroyAware(destroyHookName: string = "ngOnDestroy"): Function {
- return (target: Object, key: string): void => {
- let originalDestroyHook: Function;
- if (destroyHookName in target && target[destroyHookName] instanceof Function) {
- originalDestroyHook = target[destroyHookName];
- }
- Object.defineProperty(target, destroyHookName, {
- value: function value(...args: any[]) {
- if (originalDestroyHook instanceof Function) {
- originalDestroyHook.apply(this, args);
- }
- this[key].next(true);
- this[key].complete();
- }
- });
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment