Friday, September 15, 2017

Data class in JsInterop

Hi, I need the following code needs to be generated:

function f(a,b) { return { a:a, b:b }; } 

This is super - easy in JSNI mode. However to be in the modern stream and to be portable I trying to do that using JsInterop

@JsType(namespace = JsPackage.GLOBAL)
public class JsClass {
  public String a,b; 

  @JsIgnore
  public JsClass(String a, String b) { this.a=a; this.b=b; }
}

It seems to be working, however in the compiled code I see something super strange I can not understand:

function a_g$(){
  a_g$ = Object;
}

function Ezf_g$(){
  Ezf_g$ = Object;
  a_g$();
}

function a3i_g$(a_0_g$, b_0_g$){
  Ezf_g$();
  i_g$.call(this);
  this.$init_1758_g$();
  this.a = a_0_g$;
  this.b = b_0_g$;
}

_.$init_1758_g$ = function Fzf_g$(){
  Ezf_g$();
}


where Ezf_g$ seems to be doing nothing, i_g$.call(this) is doing nothing, this.$init_1758_g$() is doing nothing, and a_g$() is doing nothing. 

What is this all for ? What am I missing? 
How go get the line I need with JsInterop ?

Thanks 


--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment