I have a single callback that I'd like triggered by multiple events. I tried
userIsActive(){
//do something
}
@HostListener('document:mousemove') this.userIsActive;
@HostListener('document:keypress') this.userIsActive;
@...
But it doesn't work, duplicate identifier 'userIsActive'
. I know I can define new functions as callbacks,
@HostListener('document:mousemove') foo1(){ userIsActive(); };
@HostListener('document:keypress') foo2(){ userIsActive(); };
@...
but creating 2 new functions with arbitrary numbers seems unnecessary and less readable. Is there a way to pass a reference to an existing callback to @HostListener
?