
TypeScript 4 Design Patterns and Best Practices
By :

Proxy is an entity that wraps an object that you require delegating operations on. This entity acts as a permission guard and controls access to the proxied object, enhancing its functionality or preventing it from calling certain methods altogether. You can also use it as a Singleton by instantiating the object at the right time.
One analogy of this pattern is a company secretary accepting calls on behalf of the company director. They can regulate the flow of calls and may or may not forward them to the director based on who is calling and why. This pattern works very similarly to the Decorator pattern that you learned about earlier. It also wraps an object and provides it with extra functionality. With Decorator, you wrapped an object with the same interface and it decorated some of the method calls. You could also add more than one Decorator to the object. However, with Proxy, you usually allow only one proxy per object, and you use it for controlling its access...