I think you could try to use a class annotated with @JsType, both for
return type and arguments...
if you pass in jQuery an object like this json:
{ "key1": "value1", "key2": "value2"}
and your code is
public MyObject call(Event event, MyObject param1, MyObject param2) { ... }
with a MyObject class like this :
@JsType
public class MyObject {
public String key1;
public String key2;
}
it should work.
The concept is that you'll rather have to manage potential runtime issue!
No compile time type checking will prevent you to invoke the function from
jquery with invalid type of the parameter...
I'm still exploring JsInterop so please correct me if I am wrong ;)
Cristiano
Il giorno venerdì 25 settembre 2015 23:33:33 UTC+2, Cristian Rinaldi ha
scritto:
>
> Hey:
>
> I'm using JsInterop to map some JS APIs.
> What is the best way to map a callback to receive multiple parameters?
>
> For example, a jQuery click handler: function (event, params)
>
> In Java could be:
>
> Function fn = new Function() {
> @Override
> public Object call(Event event, Object... params) {
> setVisible(!visible);
> return null;
> }
>
>
> but then is complicated to manipulate the "Object []", there is a more
> direct way?
>
>
--
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/006c06dd-9c64-4dbe-a3b9-b08be4d2f506%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.