Synchronise view "loading" and activity start in MVP

80 views
Skip to first unread message

Thomas Lefort

unread,
Feb 3, 2012, 4:33:06 AM2/3/12
to Google Web Toolkit
Hi,

Let's say you have a view that needs to load a library, eg the google
maps library. Some of the method offered by the view should only be
called by the activity when the map is fully loaded otherwise
resulting in errors. I need a way to hold off any UI call from the
activity until the view is fully loaded, and if loaded with errors act
accordingly. What is the recommended way of doing this with the GWT
MVP framework?

Thanks,

Thomas

Thomas Broyer

unread,
Feb 3, 2012, 7:06:24 AM2/3/12
to google-we...@googlegroups.com
Simply wait for all your code to be "loaded" (could be required scripts, or RPC/RequestFactory calls to the server) before "pushing" your view into the AcceptsOneWidget passed to the Activity#start() method.

Thomas Lefort

unread,
Feb 23, 2012, 7:14:16 AM2/23/12
to Google Web Toolkit
Hi Thomas,

Thanks for you suggestion.

Not sure that would be enough. This is my use case:
- I have 3d applet in my view, it takes a while to load, as well with
user authorisation, etc... I am able to detect when the applet has
started running though
- the view is created once and managed by client factory
- my activity loads at start up some user data, some of it to be
displayed in the applet via my view interface
- I need to be able to wait for the applet to be ready to add the user
data, at least for the first time the view has been created

This is actually just as valid for the 2d map, which I load
asynchronously via the google api library. Even if I didn't I still
need to be able to habdle the case where the library hasn't loaded at
all, reached api limit or network issue, and prevent the activity from
trying to add map data.

My current idea is to add a whenViewReady(AsyncCallback) to my view in
the activity start. This method will call the callback if the view is
already ready (immediate) or when the view is ready (upon completion
of the load). If there are better suggestions (use of event bus or
else), I am happy to hear them.

Thanks for any help,

Thomas

Patrick Tucker

unread,
Feb 24, 2012, 9:22:09 AM2/24/12
to Google Web Toolkit
This is what I have done in the past, for similar reasons as you
described.

On Feb 23, 7:14 am, Thomas Lefort <lefortho...@gmail.com> wrote:
> Hi Thomas,
Reply all
Reply to author
Forward
0 new messages