Proxy
A proxy is an object that controls access to another object, called a subject. The proxy and the subject have an identical interface and this allows us to transparently swap one for the other; in fact, the alternative name for this pattern is surrogate. A proxy intercepts all or some of the operations that are meant to be executed on the subject, augmenting or complementing their behavior. The following figure shows a diagrammatic representation:
The preceding figure shows us how the Proxy and the Subject have the same interface, and how this is totally transparent to the client, who can use one or the other interchangeably. The Proxy forwards ...
Get Node.js Design Patterns - Second Edition 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.