JsInterop Question

236 views
Skip to first unread message

Benjamin Tillman

unread,
Jul 31, 2015, 3:13:32 AM7/31/15
to GWT Contributors
Hey everyone, I posted this question on the GWT group here at the beginning of the month, but since I didn't get a reply I'm just cross-posting here :)

Just a quick question regarding JsInterop: how is it proposed to manage javascript functions that can potentially take more than one type of parameter? For example, take the websocket interface:

@JsType(prototype = "WebSocket")
public interface WebSocket extends EventTarget {

  ... blah blah.

  void send(String data);
  // void send(Blob data); <-- JsInterop forbids this

}

I suppose that the following is possible

@JsType(prototype = "WebSocket")
public interface WebSocket extends EventTarget {

  void send(Object data);

}

but ... this doesn't seem ideal from a Java perspective :)

Regards,
Ben.

Benjamin Tillman

unread,
Aug 24, 2015, 8:23:07 AM8/24/15
to GWT Contributors
Any chance of reply? If it's a bad question I'm happy to hear that as well, just so I know I'm thinking about this the wrong way.

Regards,
Ben.

Jens

unread,
Aug 24, 2015, 8:32:55 AM8/24/15
to GWT Contributors
You need to use normal JavaScriptObject + JSNI for now for these cases.

-- J.

Benjamin Tillman

unread,
Aug 25, 2015, 7:29:57 PM8/25/15
to GWT Contributors
That's fine, I was just trying to pre-empt Elemental 2.0 a bit and got the impression from the compiler complaint and some of the design docs linked here that examples like the above wouldn't be possible.

Regards,
Ben.
Reply all
Reply to author
Forward
0 new messages