What's the second argument to HostListener for and why is it often given as ['$event']?
$event
is the reserved name for the actual event value like it can be used in (click)="clickHandler($event)"
event bindings.
@HostListener('eventName', args)
supports an array of values like
['$event.target.value', '$event.name']
that specifies what values will be passed as parameters to the event handler.
It looks like just always passing $event
(assuming ['$event']
as default) would be a more reasonable approach,
but if WebWorker is used, this way the amount of data passed between UI thread and WebWorker thread can reduced by only passing that part(s) of the event that are actually required by the event handler (or no value at all if the parameter is omitted).
See also https://angular.io/api/core/HostListener#args