Chapter 5. Proxying the Model

The PureMVC framework’s Proxy class is a pretty simple affair. It has a few life cycle methods that are called when it is registered and removed; an Object typed data property with attendant getData and setData methods; and it can send notifications to communicate one-way with Mediators or trigger execution of Commands.

It is so simple a class that it almost seems worthless, as a blank sheet of paper might once have appeared before receiving the first words of Catcher in the Rye. But because of this simplicity and the PureMVC Model that acts as a registry for Proxys within the system, it turns out to be really useful. It does not impose much on you in the way of rules; as a best practice, it should not know any of the View or Controller tier classes, and that is really about it.

Note

Proxys are usually long-lived actors within your system, registered at startup and present throughout runtime. Proxy instances that may be created and removed dynamically are therefore referred to as transient.

You usually subclass the framework Proxy class, and then add your own functionality, but as you will see, our Proxy subclasses will also use transient Proxy instances to keep track of the individual VOs that we create or load into memory. This is the Proxy in its simplest form; a simple way of stashing an arbitrary piece of data so that we can retrieve it quickly by name later. We could as easily keep an Array of all StoryVOs as a property of the StoryProxy, for instance, ...

Get ActionScript Developer's Guide to PureMVC now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.