puremvc
|
 |
« Reply #1 on: March 23, 2011, 07:54:20 » |
|
Both Proxy and Mediator can be instantiated and used, though 99.99999999% of the time they are subclassed.
For instantiating Proxy, you may simply want a named data object that can be retrieved from the Model. Dynamically created objects for a game, perhaps. Or interim values in a large calculation that takes async breaks to keep from going compute-bound.
These objects don't have to have a custom Proxy subclass with methods for manipulating them. In this case the Model is merely an object registry, and the Proxy a thin wrapper for placing arbitrary objects into the registry and retrieving them.
The case for instantiating Mediator is much the same. Perhaps you're generating gobs of sprites for your game. You can use the View as an object pool, wrapping your objects in thin wrapper that Commands retrieve by name (perhaps from a simple array of names stored in a Proxy instance) and act upon.
Sure, if you need object pooling, you could write something to do that, but if you're already using PureMVC, why would you bother? Model and View are functional registries out of the box.
-=Cliff>
|