Send event to all currently loaded modules only

9 views
Skip to first unread message

Dennis

unread,
Oct 7, 2010, 11:35:12 AM10/7/10
to Mvp4g
Hi,

In my multi-module app I have a general 'reset' event that all
presenters implement. The reset event is triggered for instance when
the user logs out. This will have the effect that also currently not
loaded modules get loaded (due to code splitting) and the event
forwarded to their presenters, which does not make sense in this case
(there is no need to reset something that is not there). Is there any
way to avoid this?

thanks,

Dennis

Pierre

unread,
Oct 7, 2010, 6:05:34 PM10/7/10
to Mvp4g
Hi Dennis,

Right now I don't think it's possible to send an event to a presenter/
child module without it to be instantiated/loaded (in other words,
it's not possible to ignore presenter/child module that aren't
instantiated/loaded).

For my current application, when we log in/out a user, we to fire the
current history token. This way we can reset our application to the
state it was before the log in/log out but by integrating the new
state of the user (the history converter is in charge of retrieving
the state of the user before firing the event stores in the history
token). Firing the current history token doesn't reload your
application.

Now this solution may not work for you and it could be nice to improve
the framework to cover the case you described. We could add a new
parameter to @Event to indicate if presenter/child modules not
instantiated should be ignored or not.

@Event(...,ignoreNotBuilt=true)
void oneEvent(...)

maybe a better name could be found for the attribute (instead of
ignoreNotBuilt).

What do you think?

Thanks,
Pierre

Dennis

unread,
Oct 29, 2010, 3:13:46 AM10/29/10
to Mvp4g
Hi Pierre,

sorry for the late reply, I was away for a while. I think you are
totally right, such an annotation on event would be the way to go
(keeping the current behavior when not specified). Regarding the name,
I tried to brainstorm a bit: onlyWhenLoaded, ignoreUnloaded,
ignoreNotLoaded, triggerAll, forceLoad, forceBuild. I kind of like the
'forceLoad' - when 'true' -> load all not loaded presenters then
trigger event, when false only dispatch to currently loaded
presenters. But I'm also poor at naming. Maybe someone else has a
better idea?

thanks,
Den

Pierre

unread,
Oct 29, 2010, 8:47:31 AM10/29/10
to Mvp4g
What about the name "passive"? A passive event would be an event that
doesn't load/build presenters/modules. What do you think?

Pierre
> > > Dennis- Hide quoted text -
>
> - Show quoted text -

Dennis Rietmann

unread,
Oct 29, 2010, 10:30:52 AM10/29/10
to mv...@googlegroups.com
somehow for me that sounds more like a description of what the event
does: The event itself would be 'passive' (e.g. doesn't modify any data).
But I could totally live with it.
Maybe we can just say what it does: 'loadModules' or
'loadAdditionalModules'.

Den

Pierre

unread,
Oct 29, 2010, 4:51:31 PM10/29/10
to Mvp4g
> Maybe we can just say what it does: 'loadModules' or
> 'loadAdditionalModules'.
This name may be confusing because this feature will also prevent
presenters to be built.

I created an issue for it (issue 53) so if we come up with a better
idea for the new attribute name by the time this feature is
implemented, we can always change it.

Pierre

Dennis Rietmann

unread,
Oct 29, 2010, 5:24:14 PM10/29/10
to mv...@googlegroups.com
yeah you're totally right. I agree that 'passive' is the best then so far.
Reply all
Reply to author
Forward
0 new messages