I have an issue with Classes in TypeScript. each time I have to listen to an HTML Element events I need to use Function.bind() to connect it to the current instance.
class VideoAdProgressTracker extends EventDispatcher
{
private _video:HTMLVideoElement;
constructor(video:HTMLVideoElement)
{
super();
this._video = video;
this._video.addEventListener("timeupdate", this.handleTimeUpdateEvent);
}
private handleTimeUpdateEvent(event)
{
// Something
}
}
I don't have to save the bound anonymous function each time when you have 5-10 events it will become a mess. I want to just have it bound.
any suggestions?