Use an EventBus to manage star icons
Image widgets that need to track the starred state of a change
register themselves on the EventBus when the widget is attached to
the DOM, and automatically unregister when the widget is removed
from the DOM. This ensures there are no memory leaks in the browser.
Events can be fired on the event bus to update UI widgets with the
new status of the star, enabling the UI to immediately reflect what
the user has done.
Toggle star RPCs are batched and sent in the background, with at most
one star RPC pending at any one time. If the user rapidly clicks a
lot of search results to be starred, these will batch and send as
soon as the first star action is updated. On slower networks this
will run more quickly than starring each change individually. In
the common case of starring a single change, the batching has no
additional overhead
If any RPC fails the pending stars are undone in the UI and an
error is shown to the user. Any outstanding batch is discarded.
Change-Id: I7ea46d2e2ee5c64c0d807677859cfb7d90b8966a
6 files changed