Displayable should provide special methods to add event listeners
jhnns opened this issue · 1 comments
Since adding event listeners is very common when using a Displayable, the Displayable should provide a wrapper method, that adds the event listener, but will also remove the event listener automatically on dispose.
A developer would use this function like this:
this.watch(someEventEmitter).on("bla", function () {});
By this call, the eventEmitter instance, the event type and the listener can be registered and automatically be removed on dispose.
Sad but true. I've removed the Disposable.class again because it introduces new possibilities of memory leaks ^^. What happens if the parent disposable doesn't ever get disposed? In this case the child disposable won't be disposed either (although someone called .dispose()
on it) because the parent disposable still has a reference on it. So I decided to keep it simpler.
It was just an experiment.