Last active
November 9, 2018 13:37
-
-
Save WouterSpaak/cf3ed9518cffbe4b530125bfd518d4f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { HostListener } from '@angular/core'; | |
import { UnaryFunction, Observable } from 'rxjs'; | |
export function ObservableHostListener( | |
eventName: string, | |
args?: string[], | |
operator?: UnaryFunction<Observable<any>, Observable<any>> | |
): PropertyDecorator { | |
// Calling HostListener will return a decorator, ready to | |
// be used by TypeScript. | |
const preparedDecorator: (target: any, key: string) => void = HostListener(eventName, args); | |
// Returning a PropertyDecorator here, in which preparedDecorator | |
// will have to be called to register the event name with Angular's | |
// change detection mechanism. | |
return (target: any, key: string) => { | |
// what to do here? | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment