Thanks a lot for your answer.

I tried the solution with defender methods earlier but it did not work, as
far as i remember the compiler refused @JsOverlay defender methods on the
JsFunction. The @JsFunction documentation says that : "A JsFunction
interface cannot have defender methods."
I will try again in this direction and let you know if i find a bug.

Thanks
Arnaud

Le ven. 2 sept. 2016 à 05:28, 'Goktug Gokdogan' via GWT Contributors <
[email protected]> a écrit :

> The limitation around @JsFunction is basically driven from the limitations
> of being a function. I think there was an earlier discussion in the
> contibutor list where we explained this in more detail.
>
> Being said that, you can handle some overloading in JsFunction interfaces
> via defender methods marked with @JsOverlay that are delegating to a main
> method. Something like:
>
>
> @JsFunction
> public interface Resolver<T> {
>
> void resolve(Object value);
>
>         @JsOverlay
> default void resolve() { resolve(null); }
>         @JsOverlay
> default void resolve(T value) { resolve(value); }
>         @JsOverlay
> default void resolve(Promise<T> value) { resolve(value); }
> }
>
> Let's us know before it is too late if you hit any bugs around this :)
>
>
> On Tue, Aug 30, 2016 at 7:13 AM, Arnaud TOURNIER <[email protected]>
> wrote:
>
>> Oh thanks! I'll try that.
>> Once I think we need to merge our work on those topics...
>> Thanks!
>>
>> Le mar. 30 août 2016 16:06, Paul Stockley <[email protected]> a
>> écrit :
>>
>>> If you are passing  Resolver<T> into some function. You could instead
>>> create 3 Resolver interfaces and then overload the function so that it took
>>> each of the resolver interfaces.
>>>
>>>
>>> On Saturday, August 27, 2016 at 9:51:50 AM UTC-4, Arnaud TOURNIER wrote:
>>>>
>>>> Hi,
>>>>
>>>> I am playing with js Promises and maybe there's a problem with
>>>> JsInterop or i don't understand something.
>>>>
>>>> When wrapping the promises with JsInterop, i come to define the
>>>> Resolver interface which represents the resolving callback that is given
>>>> when constructing a promise. In Javascript it is a function and not an
>>>> object, so the interface has the @JsFunction annotation.
>>>>
>>>> Here is the Resolver interface (inspired from the TypeScript definition
>>>> of Promises...) :
>>>>
>>>> @JsFunction
>>>> @FunctionalInterface
>>>> public interface Resolver<T>
>>>> {
>>>> void resolve( T value );
>>>> }
>>>>
>>>> Since the Javascript "resolve" function can be called without
>>>> parameters and also with a Promise instead of a value, i would like to make
>>>> those versions available in the interface.
>>>>
>>>> But the @JsFunction annotation prevents from having this :
>>>>
>>>> @JsFunction
>>>> public interface Resolver<T>
>>>> {
>>>> void resolve();
>>>>
>>>> void resolve( T value );
>>>>
>>>> void resolve( Promise<T> value );
>>>> }
>>>>
>>>> That's because it allows only one method in the annotated interface.
>>>>
>>>> That is what i don't understand : AFAIK, the gwt compiler has to call
>>>> the same function in the same way for the three declared methods (because
>>>> of the semantic of the @JsFunction annotation), just changing the calling
>>>> parameters. So i don't understand why is there the limitation of having
>>>> only one method allowed in @JsFunction interfaces... If it would it would
>>>> give even much power to JsInterop !
>>>>
>>>> Could you please bring light to my misunderstanding ?
>>>>
>>>> Thanks !
>>>>
>>>> Arnaud
>>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "GWT Contributors" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/google-web-toolkit-contributors/pNmyrzkfPWo/unsubscribe
>>> .
>>> To unsubscribe from this group and all its topics, send an email to
>>> [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/google-web-toolkit-contributors/a5ebf0e5-2e7f-40b9-ac82-a52c4b9ee5a6%40googlegroups.com
>>> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/a5ebf0e5-2e7f-40b9-ac82-a52c4b9ee5a6%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>>
> You received this message because you are subscribed to the Google Groups
>> "GWT Contributors" group.
>>
> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/google-web-toolkit-contributors/CANjaDnd6AzYDRpzLdPFkpzw5j6To6BN-22NqPyQVyaB9ER%2B9hQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/CANjaDnd6AzYDRpzLdPFkpzw5j6To6BN-22NqPyQVyaB9ER%2B9hQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>
>
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "GWT Contributors" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/google-web-toolkit-contributors/pNmyrzkfPWo/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAN%3DyUA0eP2NCTC6nWX8y4dF6T4X0TdSrJWVuGk_7E1KKoLs_bA%40mail.gmail.com
> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAN%3DyUA0eP2NCTC6nWX8y4dF6T4X0TdSrJWVuGk_7E1KKoLs_bA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/CANjaDndYyVk4eH%2BCzKkBVpBgtBChX9e-sBspVHmmPcgHM1NiLw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to