CHAPTER 14The Proxy Pattern

In this chapter, we look at the proxy pattern. A proxy is an object that can be used to control access to another object. It implements the same interface as this other object and passes on any method invocations to it. This other object is often called the real subject. A proxy can be instantiated in place of this real subject and allow it to be accessed remotely. It can also delay instantiation of the real subject until it is actually needed; this is especially useful if the real subject takes a long time to initialize, or is too large to keep in memory when it isn't needed. Proxies can be very helpful when dealing with classes that are slow to load data to a user interface.

The Structure of the Proxy

In its most ...

Get Pro JavaScript™ Design Patterns 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.