On Sunday, January 22, 2012 5:38:22 PM UTC+1, Mike H wrote:
>
> Thanks for taking the time to read my post and reply Thomas. So, just 
> to make sure I understand, have you implemented the Activity as a 
> singleton to prevent the Activity Manager reloading the same activity?
>

Not a singleton, but we're using some kind of "caching" in the 
ActivityMapper, something really similar to a CachingActivityMapper (but we 
baked it into our mapper). Something like:
if (shouldReturnSearchActivity) {
   if (lastSearchActivity == null) {
      lastSearchActivity = createSearchActivity();
   }
   return lastSearchActivity;
} else {
   // don't keep the activity forever, let it be garbage collected
   lastSearchActivity = null;
   // handle all other cases
}

If so, do you still need to know in the Activity if it is currently in 
> a  "started" state?
>

All our activities share a common ancestor that already tracks this for us, 
and we check "isActive() && event.getNewPlace() instanceof OurSearchPlace" 
in the PlaceChangeEvent.Handler, but I'm not sure it's needed (the 
instanceof would be enough to tell whether we're still on the activity or 
already navigating away).

In retrospect, I think passing the info from the ActivityMapper (as you 
suggested) is "cleaner", as our approach tightly couples the activity and 
the places (which is the responsibility of the ActivityMapper).

Just to expand on why I think these are bad solutions - I think I 
> consider my attempts bad solutions because they all seem to be trying 
> to get round a limitation of the Activity Manager - even with your 
> solution, is it right that the Activity Manager is bypassed and the 
> Activity itself is coupled to the PlaceChangeEvent? I thought the idea 

of the Place Controller and Activity Manager was to avoid the 
> activities having to be concerned about handling these events. Also, I 
> assume your Activity must have to look inside the PlaceChangeEvent to 
> check if it is for the Place associated with the Activity? If so, this 
> is really the job of the ActivityMapper, and having the Activity know 
> what Place it is duplicates that information in two places.


Yes. In retrospect, I think passing the info from the ActivityMapper (as 
you suggested) is "cleaner", as it avoids the coupling: the activity simply 
exposes an API advertising that the filter can be changed midway between 
the activity's start() and onStop(), and the ActivityMapper takes advantage 
of it.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/zt8B4E6rZSwJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to