I’m currently experimenting with custom (level 2 DOM) events and I’ve now arrived at the problem that addEventListener() will not accept callbacks that return a value — or at least I’m unfamiliar with the proper approach to this.
Basically what I want is this:
addEventListener("customEvent",
function() {
return true ;
},
false) ;
so that if I create an instance of a wrapper function new wrapper(),
function wrapper() {
addEventListener(...) ;
}
this will properly return, true whenever the event is triggered and caught.
Please keep in mind that this is experimental: I am aware that there are a plethora of solutions that do not require a return from an addEventListener method. I’m just curious whether there is a work-around or if this is in fact a dead-end and I should not bother.
AddEventListener by specification does not and will not return a value. If addEventListener were to return a value, it would be useless as the event that triggers the callbackFunction would get the return value and not to addEventListener which merely registered it.
With that being said, there is a dirty method but it should get you what you want.