The CachingActivityMapper will return the same activity instance if asked for the same Place twice or more. However, PlaceController will not fire a PlaceChangeRequestEvent (and ultimately no PlaceChangeEvent) if I was to goTo(...) a place that equals the current one. As a result, the ActivityManager listening to those events will not do anything, that is, it won't even ask the CachingActivityMapper for an activity in this case.
So, I don't really see the point of CachingActivityMapper. Am I missing something?
CachingActivityMapperis of little (to no) use when used alone. It's really meant to be between something like aFilteredActivityMapperand yourActivityMapper.The original usecase was master-detail; for example, for a mail app, with 2
ActivityManagers, one for the list of mails (master) and the other for a specific message (detail), and we could imagine a third one with a menu or treeview; let's concentrate on the master:MailBox("inbox")FilteredActivityMapperpasses the place as-is to the underlyingCachingActivityMapperActivityMapperreturns an activity for the list of mails in the "inbox"Message(box="inbox", id="123")FilteredActivityMappertransforms the place toMailBox("inbox")CachingActivityMapperreturns the cached activity, without actually calling the wrappedActivityMapper; so theActivityManagerwon't stop and start the activity, or touch theHasOneWidgetit's managing.There can be variants, for example, the detail mapper could cache the last Message place it seen (where that Message place wouldn't contain the "mail box" information, i.e.
Message("123")), and when it receives a MailBox place, it would pass the Message place to the underlyingCachingActivityMapper, which would return the cached activity; that would allow the master to change to a new mail box while still displaying the same message in the detail panel (GMail with split display behaves more or less like this).