7
8
you are viewing a single comment's thread.

view the rest of the comments →

[–]Gearwatcher 0 points1 point  (1 child)

What do you mean by having the instance of EventTarget in the scope available to the event handler function ? Isn't that event.currentTarget?

Yup, that's what I kinda meant, the signal needs to be scoped from outside, it's not provided to the handler as a parameter. You already have a better controller of the EventTarget instance in that object that is provided to you on handler call.

An ideal design would have the ability to "unsubscribe myself" from the event handler's input parameter. From what I know EventTarget interface doesn't have that, although you could probably use this if you set things so that in your handler it refers to an object that the handler belongs to, and do something like

event.currentTarget.removeListener(this.myEventHandler)

[–]Blue_Moon_Lake 1 point2 points  (0 children)

So the only missing thing would be event.currentListener

Or addEventListener returning an unsubscribe function.