btw:  With addEventListener, we have to use hard coded strings for the 
event name.  Eg: 

img.addEventListener("load", e -> doStuff());

Or are there event name constants we can use somewhere?

On Thursday, 31 July 2025 at 7:29:07 pm UTC+10 Craig Mitchell wrote:

> Excellent  explanations.  Makes sense.  Thanks Jens.
>
> On Thursday, 31 July 2025 at 7:25:56 pm UTC+10 Jens wrote:
>
>> What I don't understand is why onload and onerror need a return value?  I 
>> just return null as I've no clue what the return value should be.
>>
>>
>> Because these on<Event> properties and their functions are defined that 
>> way. For example in the old days you could return false in an onclick 
>> function to suppress the click default action of the browser. These days it 
>> is recommended to always use addEventListener() instead of these event 
>> properties and to suppress the default action you call 
>> event.preventDefault().
>>
>> Also in JS a function basically always have some return value, e.g.
>>
>> function() {
>>   return;
>>   return undefined;
>>   // no return statement at all
>> }
>>
>> is all the same and returns undefined. That is why Promises in elemental2 
>> also feel a bit clunky compared to JS. Promises allow you to return a new 
>> Promise/thenable in your success/catch callback methods so elemental2 has 
>> to define a return type for these callback functions. If you do not want to 
>> return a Promise/thenable in JS then you simply do not write a return 
>> statement but in Java you now have to write return null.
>>
>> -- J. 
>>
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/google-web-toolkit/db240757-819a-440d-bd31-d7518c953309n%40googlegroups.com.

Reply via email to