Skip to content
This repository was archived by the owner on Dec 17, 2021. It is now read-only.

Latest commit

 

History

History
43 lines (29 loc) · 982 Bytes

proxy.md

File metadata and controls

43 lines (29 loc) · 982 Bytes

Observer.proxy()

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.

Syntax

// Wrap an object
let _obj = Observer.proxy(obj);

Parameters

  • obj - an object or array to proxy.

Return Value

Proxy

Usage

// 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.

Related Methods