Closed GoogleCodeExporter closed 8 years ago
I think here the best approach would be to set autoDisplay to false.
This way your module will still be loaded when the first event is passed to it
but
it won't be automatically displayed. You will then be able to prefetch data and
when
you're done, you can fire an event that will be forwarded to the parent module.
This event should contain one of the child module's view to ask the parent
module to
display it.
Original comment by plcoir...@gmail.com
on 1 Jun 2010 at 10:57
Thanks for your quick response to this.
I have investigated the approach your suggesting. It works, but has a
significant
draw-back. If I disable autoDisplay, I need the child modules to forward the
event
to their parent for each and every event that they may receive from the parent
to
ensure that the module's start view is rendered. In my application, I have a
parent
module with several children. Each of these children has a series of events
for
performing crud operations (view, edit, etc) and other operations more specific
to
the data. I am making use of the place mgtmt of mvp4g, and so it is possible
for an
application user to navigate directly to one of the crud events with a URL
something
like http://myappdomain.com/child/edit#id=123. With autoDisplay turned on,
"child"
automatically gets loaded. But with it off, "child" will only load if the
"edit"
event forward an event back to its parent with its view to load.
To further complicate matters, some of my child modules have their own
children, each
with its own crud events. An application user could access one of these events
via a
URL such as http://myappdomain.com/child/grandchild/edit#id=123, which means
that not
only would the "grandchild" need to forward its view to "child", but "child"
also
needs to forward its view. Ultimately, the amount of additional code and
maintenance
required as new modules and events are added makes the performance gains I
could get
from prefetching modules not worth the effort.
Original comment by cainw...@gmail.com
on 2 Jun 2010 at 1:41
I can see why it would be too difficult to implement.
By prefeching, what you would like to have, is to be able to load the child
module
code right after the main module is done loaded, so that when the user needs
the
child module, it's already there. Am I correct?
I don't see an easy way to do this now with autoDisplay activated. But it could
be a
nice feature to add, maybe for 1.3.0?
Original comment by plcoir...@gmail.com
on 3 Jun 2010 at 10:33
>> By prefeching, what you would like to have, is to be able to
>> load the child module code right after the main module is done
>> loaded, so that when the user needs the child module, it's already
>> there. Am I correct?
This is mostly correct. Only I would like the child module to load at a time
of my
choosing via an event. That way I can load child modules at times that it
makes the
most sense for the flow of the application. For example, my application has
security
built into it, and not every user gets access to every module. So, after
loading
the main module, displaying its UI, and determining which modules a user has
access
too, then I would like to load the appropriate child modules.
>> I don't see an easy way to do this now with autoDisplay activated.
>> But it could be a nice feature to add, maybe for 1.3.0?
That would be great. Thank you.
Original comment by cainw...@gmail.com
on 4 Jun 2010 at 1:39
Of course 1.2 would be better. ;)
Original comment by cainw...@gmail.com
on 4 Jun 2010 at 2:01
I guess to add prefetch feature, we could have something like this:
@ChildModules( { @ChildModule( moduleClass = ChildModule1.class, prefetch=true
)} )
public interface MainEventBus extends EventBusWithLookup {...}
This option will be useful only if autoDisplay = true & async = true. What it
will do is that, autoDisplay event won't be fired the first time an event is
forwarded to a child module.
I think this would fit your need, no?
I will try to have it in 1.2.0 if it doesn't impact the code too much.
Original comment by plcoir...@gmail.com
on 7 Jun 2010 at 10:58
Yes. That work work great for me. Thanks!
Original comment by cainw...@gmail.com
on 8 Jun 2010 at 9:44
Sorry for not getting back to you earlier on this. This feature is not part of
Mvp4g 1.2.0 but I think it can be done thanks to event filtering.
If you want to send an event to fetch your module without it to be
automatically displayed you can do this:
{{{
//noEventFilter is a filter that you need to create to stop any event
//just implement EventFilter and have filterEvent always return false
//add the filter to stop all events
parentEventBus.addEventFilter(noEventFilter);
//prevent only the next event to be filtered
eventBus.setFilteringEnabledForNextOne(false);
//fetch child module
parentEventBus.eventToFetchAChildModule();
//remove the filter
parentEventBus.removeEventFilter(noEventFilter);
}}}
This way when the child module forwards the auto-display event to its parent,
it will be ignored. Also events fired on the child event bus won't be blocked.
You can have more information about event filtering here:
http://code.google.com/p/mvp4g/wiki/EventBus#Event_Filtering
I think this will solve your problem, no?
Original comment by plcoir...@gmail.com
on 29 Sep 2010 at 5:22
Yes. I believe that this will do the trick. Thank you!
Original comment by cw...@cloudsherpas.com
on 30 Sep 2010 at 2:00
I'm invalidating the bug since, thanks to event filtering, you can prefetch
module.
Original comment by plcoir...@gmail.com
on 11 Nov 2010 at 11:55
Original issue reported on code.google.com by
cainw...@gmail.com
on 1 Jun 2010 at 3:30