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/5637485f-905b-488f-b8ab-68ea568a1d8bn%40googlegroups.com.

Reply via email to