Skip to content

Instantly share code, notes, and snippets.

@WouterSpaak
Created November 9, 2018 12:56
Show Gist options
  • Save WouterSpaak/594e185d8b187f3cfdb09e28a3038bdf to your computer and use it in GitHub Desktop.
Save WouterSpaak/594e185d8b187f3cfdb09e28a3038bdf to your computer and use it in GitHub Desktop.
@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