ArcBees / GWTP

A complete model-view-presenter framework to simplify your next GWT project.
Other
334 stars 132 forks source link

useManualReveal not working other Presenters #425

Closed confile closed 10 years ago

confile commented 10 years ago

I have a UserPresenter that inserts itself in the AppPresenter. The UserPresenter has

@Override
    public boolean useManualReveal() {
        return true;
    }

The HeaderPresenter will be inserted into another Slot from the AppPresenter. This is done in the AppPresenters onBind()

@Override
    protected void onBind() {
        super.onBind();
        setInSlot(HEADER_SLOT, headerPresenter);
}

I have also set useManualReveal to return true in the HeaderPresenter. It turns out that when I reveal the UserPresenter the HeaderPresenter is also revealed.

Well, this makes no sense the header could request some informations on could be revealed later. The AppPresenter must be revealed because it is the parent of the UserPresenter.

christiangoudreau commented 10 years ago

If you manually use setInSlot like this, you should use presenter widgets : https://github.com/ArcBees/GWTP/wiki/Presenter-Widget

confile commented 10 years ago

But then I cannot use ProxyEvent. Anyway, it doesn't solve the problem. Is it a bug or I am wrong on this issue?

christiangoudreau commented 10 years ago

You can't use proxy events, but you can bind the presenter as an eagerSingleton and use normal events.

confile commented 10 years ago

I know but this has nothing to do with the issue. On a multi slot page where more than one presenter has a manual reveal. All will be revealed after the first reveal.

christiangoudreau commented 10 years ago

It is hard to say if it is a bug, GWTP hasn't been designed to handle a N to 1 relationship between presenters and places. You can definitely build a presenter that isn't a place, not use NameToken on them, then set them manually into a slot. but don't use manual reveal in that case, I don't see why it is needed.

confile commented 10 years ago

Here is an example form my case. Consider Twitter. When you load the page you want that the user gets a response as fast as possible. First you could load the feedPresenter which contains all the feeds in the middle of the screen. Then you could load the not so important content at the left side like related topics, your user profile or what friends are new on twitter.

This would give a great user experience because the user gets a response from the page faster.

christiangoudreau commented 10 years ago

Right, but benchmarking this kind of optimisation by using codesplitting will show you that the gain in speed over the complexity of the design isn't worth it (already done that experiment in the past). I prefer separating large modules instead to have the fastest initial download in one piece instead of several ones.

You need to consider that for each Javascript files, you have an http request dans is issued. Concrete example: Initial download size: 100ko, one request, latency: 60ms Initial download size: 90ko + 3 times 3.33ko, 4 requests, latency: ~60ms for each requests. Some older browsers limit to 2 http request and each http request weight around 800bytes : http://stackoverflow.com/questions/5358109/what-is-the-average-size-of-an-http-request-response-header

Don't forget that you may have images to load, css as well, the initial html size. Those are all http requests.

So, say that every single requests loads at almost the same time and that you only have javascript files (you must first load the 90ko to know that the others exists).

That mean an average latency of 120ms instead of 60ms and a size of 103.2ko instead of 100.8ko.

So my question to you, is it worth it?

confile commented 10 years ago

I guess your are right that might be to much overhead. I will close this issue. Thank you for your answer.