Git Product home page Git Product logo

Comments (3)

cpboyd avatar cpboyd commented on May 27, 2024

It's not a huge issue in this particular case, since I'm keeping a copy of the item list in GWT and can just pull from there.

However, it could pose issues if there's other JS functions that take callback functions with more than one argument as parameters.

from gwt-api-generator.

manolo avatar manolo commented on May 27, 2024

It's almost impossible to figure out the arguments of a callback. Hydrolysis does not provide that info. Also we would need to define a hight amount of functional interfaces for all possibilities.

But because we are using the JsInterop @JsFunction, we can cast different implementations and your code would be like this:

// Define the function which matches the JS signature
@JsFunction
 public interface Function2 {
     void call(Object a, Object b);
 }
// Create your Function implementation
Function2 callback = (error, object) -> {
   if (error == null) {
       // Do something with object
   }
 };

grid.getPolymerElement().addEventListener(SelectedItemsChangedEvent.NAME, event -> {
    JsArrayNumber n = grid.getSelection().selected(null, 0, 200).cast();
     if (n.length() == 1) {
       // Cast it in the method call
        grid.getItem(n.get(0), (Function)callback, false);
     }
});        

from gwt-api-generator.

cpboyd avatar cpboyd commented on May 27, 2024

Ah, ok. That works!

Thanks!

from gwt-api-generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.