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 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/15705e1b-c1cf-46ec-add7-96d2b787f8fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to