GWT Codesplitting Integration: MVP and Activites/Places

143 views Asked by At

Let's say you have a "display region" (AcceptsOneWidget) that contains a tabbed pane. Clicking a different tab (i.e., going from "fantastico" to "profile") results with totally new content being displayed inside the pane. This seems like a perfect use case for codesplitting, because up until the user clicked the "profile" tab, they didn't need to download the code necessary to display it. (Note: If any GWT gurus disagree and don't think this is the right use case for codesplitting, then please point that out to me, but it is besides the point for this question, so please just bear with me!)

enter image description here

Now then, if my understanding of basic GWT architecture is correct, the code that is necessary to display the "profile" tab consists of Activity(ies), Place(s), perhaps some MVP stuff such as a Presenter, Module, EntryPoint, etc. Of course this will be different depending on the application and developer (as I've learned in GWT there's many ways to accomplish the same objective), but regardless, it's a bunch of MVP/Activity/Place "stuff". For the sake of this question, I like the model proposed by the answerer of this SO question.

After reading this article on the AsynchProvider pattern I'm trying to tie all these best practices together and achieve an architecture whereby:

  • I implement codesplitting such that each tab in the pane is codesplit (is is codesplitted? codesplat?) as its own fragment and will download only if/when the user clicks it for the first time
  • All the code necessary to display/render/implement each fragment (tab/pane) is neatly organized and follows the AsynchProvider patterns referenced in the above article; this allows it to be compartmentalized and have no dependencies on other fragments

I'm starting to put all the pieces together, but still not seeing how these two concepts can be tied together in working code.

I'm finding GWT to be mysterious, powerful and wonderful, but very difficult to learn without practical code examples to follow. Of course, these wireframes don't really show any complexity in the "fantastico" or "profile" panes, so again please bear with and pretend like these are both fairly sophisticated display regions with lots of rich UI components. Thanks in advance!

1

There are 1 answers

1
Thomas Broyer On

If the display region contains the tabpane, then it doesn't matter whether you're using activities or places.

To split the tab contents, it's enough to use a SimplePanel as the real tab content, and load its content by listening for the SelectionEvents.
Alternatively, you can use a LazyPanel whose createWidget will return a SimplePanel and asynchronously load the rest of the code.