As i had no luck on Google+ yet, i'll try it here.
First the G+ Post:
https://plus.google.com/116136390679208063122/posts/52kcbwwngWo
Well I just started to work on a ChromeCast Receiver built with GWT. As the
Receiver API is in JS i wanted to try JSInterop over JSNI but had some
struggle.
The ChromeCast Api has some properties that can be set with a function to
act as a callback. eg for onReady.
castReceiverManager.onReady = function(event) {
// do stuff
};
Now my question is: How can i do this with JsInterop or is it not yet
possible?
as mentioned in
https://docs.google.com/document/d/1tir74SB-ZWrs-gQ8w-lOEV3oMY6u6lF2MmNivDEihZ4
below "Single Abstract Method Handling" i tried something like this
@JsType
public interface Receiver {
@JsProperty
void onReady(Runnable onReady);
}
when trying to execute the method with this snipped i get "Exception
caught: (TypeError) : object is not a function"
private native void test(Receiver receiver)/*-{
receiver.onReady();
}-*/;
to see whats the value of onReady i did console.log(receiver) and got this:
(where onReady is set the way above and onSenderConnected has been set the
JS way inside an JSNI method.
onReady: JsTest$1_1_g$
onSenderConnected: function (event_0_g$)
is there a way to achieve this yet or do i have to wait for 2.8/3.0?
i tried to dig into the gwt code to see if there is a way to add something
to support this but unfortunately the gwt code for js processing is a bit
out of my scope.
some possible solutions would be either
interface JsFunction {
<T> T call(Object... args);
}
or
interface MyOnReadyCallback {
@JsFunction
MyReturnType anyName(String arg1, boolean arg2, SomeOtherType arg3);
}
and let the "Single Abstract Method Handling" find the method and add it.
Thanks! :)
--
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/d4c8fb2c-6060-4680-9b24-e118a452dc0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.