-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
bugSomething isn't workingSomething isn't working
Description
There seems to be a bug with paths in the Observer.
The following code:
const o = new Observer({});
o.on('*:set', (path, value, oldValue) => {
console.log(`${path} = ${JSON.stringify(value)}`);
});
o.set('theParent.0.child', { x: 1, y: 2 });Gives output:
theParent.0.child.child.x = 1
theParent.0.child.child.y = 2
theParent.0.child.child = {"x":1,"y":2}
Notice the third path should be theParent.0.child.
Looking at Observer's internal node tree suggests that all paths set here are incorrect. I believe the line should read:
_path: keys.slice(0, i).join('.')Interestingly, if theParent.0.child is set to an atomic value before assigning an object then the resulting paths appear correct. However in this case '*:set' events don't propagate up the parent tree.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working