This function wraps an object or array in a proxy with all operations on the instance forwarded to the appropriate interceptors and announced to observers.
// Wrap an object
let _obj = Observer.proxy(obj);
Parameters
obj
- an object or array to proxy.
Return Value
Proxy
// The observed object/array
let arr = [];
Observer.observe(arr, changes => {
console.log(changes);
});
// The proxy
Observer.proxy(arr).push('one', 'two');
The above operation above will notify our observer three times each for a set operation on the properties 0
, 1
, length
.