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?
CachingActivityMapper
is of little (to no) use when used alone. It's really meant to be between something like a FilteredActivityMapper
and your ActivityMapper
.
The original usecase was master-detail; for example, for a mail app, with 2 ActivityManager
s, 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")
FilteredActivityMapper
passes the place as-is to the underlying CachingActivityMapper
ActivityMapper
returns an activity for the list of mails in the "inbox"Message(box="inbox", id="123")
FilteredActivityMapper
transforms the place to MailBox("inbox")
CachingActivityMapper
returns the cached activity, without actually calling the wrapped ActivityMapper
; so the ActivityManager
won't stop and start the activity, or touch the HasOneWidget
it'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 underlying CachingActivityMapper
, 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).