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:
- The current place is
MailBox("inbox")
- the
FilteredActivityMapper
passes the place as-is to the underlying CachingActivityMapper
- the actual
ActivityMapper
returns an activity for the list of mails in the "inbox"
- the user clicks on a mail in the list, going to a new place
Message(box="inbox", id="123")
- the
FilteredActivityMapper
transforms the place to MailBox("inbox")
- the
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).