import ReactiveProxy from 'reactive-proxy';
const source = {a: { b: { c: { d: 5 } } } };
const proxy = new ReactiveProxy(source, {
get(target, prop, receiver, propPath) {
console.log("get prop:", propPath);
return Reflect.get(target, prop, receiver);
},
set(target, p, value, r, propPath, reactiveWrapper) {
console.log("set prop:", propPath);
return Reflect.set(
target,
p,
reactiveWrapper(value), // Wrap to Reactive Proxy Object
r
);
}
});
let a = proxy.a.b.c.d;
// Console Output: get prop: ["a", "b", "c", "d"]
proxy.b = {};
// Console Output: set prop: ["b"]
console.log(proxy.b) // ReactiveChild {}
proxy.b.b
// Console Output: get prop: ["b", "b"]
reactive-proxy
0.1.2 • Public • PublishedReadme
Keywords
nonePackage Sidebar
Install
npm i reactive-proxy
Weekly Downloads
0
Version
0.1.2
License
MIT
Unpacked Size
7.63 kB
Total Files
4