Code splitting

56 views
Skip to first unread message

aliwa

unread,
Jun 22, 2011, 6:39:50 AM6/22/11
to GWT Presenter
Hi all,

A simple question: how to make code splitting with gwt-presenter?
Have you an example?

thank you in advance :)

aliwa

unread,
Jun 22, 2011, 7:03:02 AM6/22/11
to GWT Presenter
I have to add that i use GIN for dependency injection.

aliwa m

unread,
Jun 23, 2011, 11:10:06 AM6/23/11
to GWT Presenter
Is there any idea plz!

Espen Amble Kolstad

unread,
Jun 23, 2011, 12:27:09 PM6/23/11
to gwt-pr...@googlegroups.com
This project is sort of dead ...
Check out GWTP (gwt-platform), where code-splitting is a nobrainer :)

- Espen

aliwa m

unread,
Jun 24, 2011, 6:26:45 AM6/24/11
to gwt-pr...@googlegroups.com
Hi,
I have worked with gwt-presenter+gwtdispatch+GIN and it is impossible to use gwtp now. do you think code splittings is feasible with these libraries?

2011/6/23 Espen Amble Kolstad <espenamb...@gmail.com>

Robert Munteanu

unread,
Jun 24, 2011, 6:35:00 AM6/24/11
to gwt-pr...@googlegroups.com
Hi,

What have you tried so far?

Robert

--
Sent from my (old) computer

Chris Lowe

unread,
Jun 24, 2011, 6:35:10 AM6/24/11
to gwt-pr...@googlegroups.com
Hello,

Code splitting is fairly straight forward with gwt-presenter - the key
is to use a GIN provider to sever the hard references to your
presenters:


import com.google.inject.Provider;

public class PresenterRegistry {

private Provider<MyPresenter> myPresenterProvider;

@Inject
public void setMyPresenter(final Provider<MyPresenter> provider)
{
myPresenterProvider = provider;
}


public void revealMyPresenter()
{
GWT.runAsync(new RunAsyncCallback()
{
@Override
public void onSuccess()
{
final MyPresenter<?> presenter = myPresenterProvider.get();
presenter.revealDisplay();
}
});
}
}

I hope that helps.

Chris.

jgonian

unread,
Jun 24, 2011, 6:37:03 AM6/24/11
to gwt-pr...@googlegroups.com
I agree with Espen. You should consider GWT-platform for your project. It is a fork of gwt-presenter but since then it has differentiated a lot and many features have become available to ease GWT (MVP) development. It also has an active community of users and contributors.  

Nevertheless, since you are using GIN, code splitting can be easily achieved with an AsyncProvider. I haven't tried it with gwt-presenter but I believe it can work. Say, you want to code split MyPresenter. Instead of injecting the presenter itself you should inject an AsyncProvider<MyPresenter> and GIN will do the rest. The javascript for the presenter will be fetched the first time that you'll ask your AsyncProvider for this presenter (i.e. myAsyncProvider.get()). 

Hope it helps,
Yannis

jgonian

unread,
Jun 24, 2011, 6:49:04 AM6/24/11
to gwt-pr...@googlegroups.com
@Chris Try to use an AsyncProvider instead of a Provider in case that you want to get rid of the GWT.runAsync stuff. GIN will take care of it.  

Cheers, 
Yannis

Chris Lowe

unread,
Jun 24, 2011, 6:55:42 AM6/24/11
to gwt-pr...@googlegroups.com
Ah, yes - good call. I came up with my solution prior to GIN's
implementation of AsyncProvider. I get the same end result though and
it's worked well for us for a while now.
Reply all
Reply to author
Forward
0 new messages