Replies: 1 comment
-
update function createObservable(_target) {
if (typeof _target === "object") {
const _val = {};
const keys = Object.keys(_target);
for (let i of keys) {
const item = _createObservable(_target[i]);
_val[i] = item;
}
return new Proxy(new Observable(_val), {
get(target, name) {
console.log(name)
return target.get()[name];
},
set(target, name, newVal) {
target.get()[name].set(newVal);
return true;
},
});
}
return new Observable(_target);
} but this function doesn't work。 let test = observable({ a: 1, b: { c: 2, d: { e: 3 } } });
console.log("start", test);
console.log(test.b.d.e);
autorun(() => {
console.log("test2", test.b.d.e);
});
console.log(dependencer);
test.b.d.e = 4; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is my code:
this code has some question:
dependencer
how do i complete this
createObservable
?thanks :-)
Beta Was this translation helpful? Give feedback.
All reactions