methods • Proxy objects acquire an Updater's reference via its static method to • Ensure acquired object is a singleton object • Keep their relationship to be loosely coupled • Asynchronous and batch remote object update • Scheduled with window.requestIdleCallback • Requests are cached in updater
Sub-classing approach encourage us to write rigid code • Explicit and easy to understand • Hard to extend • Proxy approach allows us to write extensible code • We can extend classes by decorating them with proxies • Code readability tends to be low
override fundamental features with Proxy • e.g. setters / getters / constructors / function calls • Target, handler, traps • Implicit inheritance: create anonymous sub-class of target's class • We can separate remote object updating code from models with proxies • Be careful when you use proxies as React components' props or states