I have a gwt module, and it is working with Jsinterop for reuse some 
functions that are on JS.

now we are trying to call a function on JS, thas is a promise. so when we 
call it from GWT it doesnt wait to the promise to resolve.. so we are 
getting an undefined result.

it could be replicated with this:


JS Code
bnb = { test: {client:{}} };
    bnb.test.client.Foo = function() {
         this.x = 4;
         this.y = 2;
    };
    bnb.test.client.Foo.prototype.sum = function() {
    setTimeout(function () {
    return(thisx + this.y);
    }, 100);
     };

    function inicial(){
    bnb.test.client.Foo.prototype.sum();
    
    }


GWT
package bnb.test.client;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Window;
public class FooMain {
  public static void main() {
    Foo foo = new Foo();
    int res = foo.sum();    
    Window.alert(" res : " + res);
    foo.x = 5;
    foo.y = 5;
    int res2 = foo.sum(); 
    Window.alert(" res2 : " + res2);
  }
}

with the timeout acting as a promise we get the undefined return value...

How we can do to wait the promise get resolved, and then go to gwt with the 
correct value.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to