Skip to content

Instantly share code, notes, and snippets.

View Jonatthu's full-sized avatar
:octocat:
Hacking

Jonathan Jonatthu

:octocat:
Hacking
View GitHub Profile
@Jonatthu
Jonatthu / subscriptions.ts
Created January 4, 2018 18:15
Observer decorator for unsubscribe on ngOnDestroy - Angular 4
import { ISubscription } from 'rxjs/Subscription';
/**
* Subscription holder that will call ubsubscribe() function when ngOnDestroy
*/
export function Observer() {
return function logProperty(target: any, key: string) {
const observerKey = 'OB' + key;
const observerValue = 'observerSOD';