com.threerings.crowd.client
Interface PlaceView

All Known Implementing Classes:
PlacePanel

public interface PlaceView

This interface provides a convenient means for decoupling user interface components that interact with a place object and that need to keep themselves up to date when the client moves from place to place.

In general, such components need to know when the client is about to enter a place so that they can subscribe if necessary or at least extract information about the place. They also need to know when a client has left a place so that they can unsubscribe and clean up after themselves. This is the information that the place view interface makes available to them in a decoupled way.

The part of the client implementation that is responsible for the main user interface can act as a location observer, and it can make use of PlaceViewUtil to dispatch notification of place changes to every PlaceView implementing user interface element in the user interface hierarchy with calls to PlaceViewUtil.dispatchWillEnterPlace(java.lang.Object, com.threerings.crowd.data.PlaceObject) and PlaceViewUtil.dispatchDidLeavePlace(java.lang.Object, com.threerings.crowd.data.PlaceObject). These functions traverse the UI hierarchy (starting with the element provided which would generally be the top-level UI element, and dispatch calls to willEnterPlace(com.threerings.crowd.data.PlaceObject) and didLeavePlace(com.threerings.crowd.data.PlaceObject) respectively on any UI element they find that implements PlaceView.

By doing this, the client code can simply create place-sensitive user interface elements and stick them in the user interface and essentially forget about them, knowing that they will all be notified of place entering and exiting by virtue of the single dispatching calls. It is useful to note that place-sensitive user interface elements will also generally need a reference to the CrowdContext derivative in use by the client, but those are best supplied at construct time.


Method Summary
 void didLeavePlace(PlaceObject plobj)
          Called after the client has left a place and needs to clean up after the user interface that was displaying that place.
 void willEnterPlace(PlaceObject plobj)
          Called when the client has entered a place and is about to display the user interface for that place.
 

Method Detail

willEnterPlace

void willEnterPlace(PlaceObject plobj)
Called when the client has entered a place and is about to display the user interface for that place.

Parameters:
plobj - the place object that was just entered.

didLeavePlace

void didLeavePlace(PlaceObject plobj)
Called after the client has left a place and needs to clean up after the user interface that was displaying that place.

Parameters:
plobj - the place object that was just left.