Object.observe() method was used for asynchronously observing the changes to an object. It provided a stream of changes in the order in which they occur. However, this API has been deprecated and removed from browsers. You can use the more general
Proxy object instead.
The Proxy object is used to define custom behavior for fundamental operations (e.g. property lookup, assignment, enumeration, function invocation, etc).
- Placeholder object which contains traps.
- The methods that provide property access. This is analogous to the concept of traps in operating systems.
- Object which the proxy virtualizes. It is often used as storage backend for the proxy. Invariants (semantics that remain unchanged) regarding object non-extensibility or non-configurable properties are verified against the target.
var p = new Proxy(target, handler);
- A target object (can be any sort of object, including a native array, a function or even another proxy) to wrap with
- An object whose properties are functions which define the behavior of the proxy when an operation is performed on it.