v 0.2.0

@onEvent


A decorator to subscribe to an event on the target element. The event listener will be automatically unsubscribed when the element is disconnected.

Please note the method binding is not necessary, as the method is bound to the instance of the class by default.

It accepts an object with one of the following properties:

And the following properties:

@onEvent({ selector: "button", type: "click" }) doSomething() {...}
@onEvent({ ref: "my-ref", type: "click" }) doSomething() {...}
@onEvent({ window: true, type: "resize" }) doSomething() {...}
@onEvent({ document: true, type: "keydown" }) doSomething() {...}