Created
November 9, 2018 12:56
-
-
Save WouterSpaak/594e185d8b187f3cfdb09e28a3038bdf 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
@Directive({ | |
selector: '[mouseClick]' | |
}) | |
export class MouseClickDirective implements OnInit { | |
private readonly clicks$ = new Subject<MouseEvent>(); | |
private readonly someStream$: Observable<any>; | |
@HostListener('click', ['$event']) handleClick(click: MouseEvent) { | |
this.clicks$.next(click); | |
} | |
ngOnInit() { | |
this.someStream$ = this.clicks$.pipe( | |
// do meaningful stuff here | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment