Question

My app is a typical GWT application, it has a navigation bar, when click one bar item, the place will be changed and the app will find corresponding activity for that place(done in MasterActivityMapper), then call activity.start(). During the init of activities, the corresponding views were also created. When my app first starts, it will by default select the first navigation bar item.

public class MasterActivitiesMapper implements Activity
{
      public Activity getActivity( Place place )
      {  
          if(place equals place1)
          {
             Activity1 a1= new Activity1();
             return a1;
          }
          else if(place equals place2)
          {
             Activity1 a2= new Activity2();
             return a2;
          }
          else if(...)
          {
             ....
          }
      }
}

My app works well except that the initial download size is too large, it will takes 10 seconds to load. I have to use code split the solve this problem.

I read the doc https://developers.google.com/web-toolkit/doc/latest/DevGuideCodeSplitting However still can not figure out where/how to split the code, could anybody has experience with this help?

Was it helpful?

Solution

Activity.start, being asynchronous by nature, seems like a good place to put a GWT.runAsync.

There's also the possibility of returning an activity async proxy from your ActivityMapper. See http://code.google.com/p/google-web-toolkit/issues/detail?id=5129 and https://gist.github.com/3038878 for some sample code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top