Friday, October 28, 2016

Code splitting and interfaces

Hi All,

I have a some problems with the GWT code splitting in the case that one module calls a method from another module that expect an interface.

Lets say that we two modules in our project named ModuleA and ModuleB. 
ModuleA is executing a method from ModuleB which expect an interface.
Now ModuleA is providing an implementation for that interface and calling ModuleB.

Here a very simple example: 

    
public class ModuleA {

   
public void execute() {
        GWT
.runAsync(ModuleA.class, new RunAsyncCallback() {
           
@Override
            public void onFailure(Throwable throwable) {}

           
@Override
            public void onSuccess() {
                executeInternal
();
           
}
       
});
   
}

   
private void executeInternal() {
        ModuleAFunc moduleAFunc = new ModuleAFunc();
        moduleAFunc.doSomething();

       
ModuleB.Callback callback = new ModuleB.Callback() {
           
@Override
            public void done() {
               
ModuleAFunc moduleAFunc = new ModuleAFunc();
                moduleAFunc
.doSomething();
           
}
       
};

        ModuleB moduleB = new ModuleB();
       moduleB.execute(callback);
   
}
}

public class ModuleB {

   
public void execute(Callback callback) {
        GWT
.runAsync(ModuleB.class, new RunAsyncCallback() {
           
@Override
            public void onFailure(Throwable throwable) {}

           
@Override
            public void onSuccess() {
               
ModuleBFunc moduleBFunc = new ModuleBFunc();
                moduleBFunc
.doSomething();
               
callback.done();
           
}
       
});
   
}

   
public interface Callback {
       
void done();
   
}
}

I would expect that the code of "ModuleAFunc" will be put into the splite point "ModuleA" and the code of "ModuleBFunc" will be added to the splite point "ModuleB".

But this is not the case. The code of the class "ModuleAFunc" will be moved into the left over code because the GWT compiler thinks that "ModuleAFunc.doSomething" is also accessible from ModuleB because
ModuleB is executing the interface method Callback.done(). 
Somebody and idea how to handle this problem???

BR
Rocco


--
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