randombits-org / gwt-presenter

Implementation of the Presenter section of a Model-View-Presenter (MVP) pattern.
2 stars 1 forks source link

Lazy Loading of Presenter which provides Places #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
If a presenter is providing a Place, then the presenter has to be
instantiated at the start of the application.

What is the expected output? What do you see instead?
It would be nice, if there is a way to register the Places with the
corresponding Presenter without actually instantiate the presenter. Maybe
there is an easy and clean solution with the Providers from Gin.

Original issue reported on code.google.com by imsan...@gmail.com on 27 Aug 2009 at 11:30

GoogleCodeExporter commented 9 years ago
Yeah, I've been thinking about better ways to have Places defined. Possibly 
having
subclasses of Place which define the rules, rather than just creating instances 
of
Place itself. How would you see a Place request configuring and initialising a
Presenter exactly?

For the record, you can just create a PlaceRequestHandler instance yourself and 
do
whatever you like with it. It just needs to be registered with the EventBus to 
be
triggered.

Original comment by Bitmei...@gmail.com on 27 Aug 2009 at 3:08

GoogleCodeExporter commented 9 years ago

Original comment by Bitmei...@gmail.com on 1 Sep 2009 at 11:33

GoogleCodeExporter commented 9 years ago

Original comment by Bitmei...@gmail.com on 1 Sep 2009 at 11:38

GoogleCodeExporter commented 9 years ago
> How would you see a Place request configuring and initialising a
Presenter exactly?
I haven't found THE solution yet. I will investigate some more, if the time 
permits.

Original comment by imsan...@gmail.com on 2 Sep 2009 at 7:36

GoogleCodeExporter commented 9 years ago
Ok, keep me posted. FYI, I have been doing some work by which Place becomes an
abstract base class and you create a concrete subclass for every actual 
location. In
the current implementation, the Place gets a link to a Presenter (injected by 
GIN in
my case). However, it could be a Projector Class in another instance, or 
nothing at
all, and the Place simply constructs the Presenter instance when it likes. The 
trick
is still figuring out how to actually put the presenter's display code into the 
right
place in the UI. But not impossible by any means.

Original comment by Bitmei...@gmail.com on 2 Sep 2009 at 7:52

GoogleCodeExporter commented 9 years ago
This is an aside, but do you have a branch for these Place changes?  I like the 
idea
of them being decoupled from the Presenter.

Another thing to consider is code splitting
(http://code.google.com/p/google-web-toolkit/wiki/CodeSplitting).  This feature 
is
currently in the trunk of GWT.

Original comment by K.Adam.C...@gmail.com on 7 Sep 2009 at 2:16

GoogleCodeExporter commented 9 years ago
@RE: comment #1

That's not true, we can't really do that because onPlaceRequest is protected.  
So even 
if we have a custom PlaceRequestHandler, that custom class won't be able to 
pass in any 
parameters found in the place request.  It would need to bind the selected 
presenter, 
unregister itself, fire the place request it is handler and re-register itself.

Original comment by pjul...@gmail.com on 13 Sep 2009 at 2:02

GoogleCodeExporter commented 9 years ago
An update on this - the changes I mentioned have been posted in the 
'branches/replace' branch. Place is now 
quite independent from Presenter, and most Presenters won't even know about any 
Places, and hardly ever their 
own Place. A Place implementation could lazy-load (or even use code splitting) 
to create the Presenter when 
triggered.

Original comment by Bitmei...@gmail.com on 3 Nov 2009 at 2:27

GoogleCodeExporter commented 9 years ago
I've just implemented this in my project. Using the idea here 
(http://www.amateurinmotion.com/articles/2009/11/02/async-with-gin.html). Need 
to 
extend PresenterPlace and override things like reveal() to be called in the 
callback 
of the load method.

e.g.
    @Override
    public void reveal() {
        loader.load(new ModuleLoader.ModuleLoaderCallback<T>() {

            public void onLoaded(T module) {
                presenter = module;
                module.revealDisplay();
            }
        });
    }

Original comment by bharri...@gmail.com on 19 Jan 2010 at 6:26

GoogleCodeExporter commented 9 years ago

Original comment by robert.munteanu on 6 Sep 2010 at 2:03