Comments (4)
I think I see the problem, but would like to ensure that we are on the same page :).
If I'm running your case, which in itself an interesting and absolutely correct one, while the observer
function looks like:
function dataObserver(changes) {
changes.forEach(change => console.dir(change));
}
i'm not getting any exception, nor in browser neither in Node, but the oldValue
that is being returned as part of the change
object is actually empty.
If you'll be able to spend few more minutes and confirm that, than I'll adjust the issue to more precise one and will better explain what is happening.
Thanks in advance.
from object-observer.
With your observer function I'm not getting the error either. Message appears as
UpdateChange {}
indicating an empty object I suppose. Debugger shows that a change object with correct oldValue is going in.
Looking at the UpdateChange
object in my observer function in a debugger I too see its oldValue
as
Proxy { b1: "x", b2 : "y}
https://stackoverflow.com/questions/11954152/whats-the-difference-between-console-dir-and-console-log is interesting reading. All new to me.
Cheers,
Michael
from object-observer.
Fixed in 0.2.5
The following test case is part of the tests suite and covering this issue:
suite.addTest({name: 'Object.assign on observable should raise an event/s of update with non-proxified original object'}, function(pass, fail) {
let oldData = {b: {b1: "x", b2: "y"}},
newData = {b: {b1: "z"}},
observable = Observable.from(oldData),
events = [];
observable.observe(changes => events.push.apply(events, changes));
Object.assign(observable, newData);
if (events.length !== 1 || events[0].type !== 'update' || events[0].path.join('.') !== 'b') {
fail('UPDATE event metadata NOT as expected');
} else if (!events[0].value || events[0].value.b1 !== 'z') {
fail('UPDATE event (new) value NOT as expected');
} else if (!events[0].oldValue || events[0].oldValue.b1 !== 'x' || events[0].oldValue.b2 !== 'y') {
fail('UPDATE event oldValue NOT as expected');
}
pass();
});
Thanks goes to @HiroP0 for the time and the efforts.
I'm closing this one, please feel free to re-open/feed-back if this one is still not working for you.
from object-observer.
Works!
Quick and thorough.
Cheers.
from object-observer.
Related Issues (20)
- Add TS definitions for convenience
- fix TS definition of Observable
- fix ChangeType type in TS definition
- the options should be optional on ObjectObserver's observe type definition
- Access the original object + some ideas HOT 6
- externalize `[un]observe` API - eliminate source modification
- Clean up the patching source code HOT 1
- Any way to prevent changes? HOT 2
- Exported CommonJS package HOT 15
- Request: Lite Version of Object Observer HOT 2
- Allow omission of observed keys and handling of cyclic references HOT 2
- handle correctly circular shaped object passed for observation HOT 3
- Wildcard path HOT 1
- Unwrapping proxies, getting the original raw object HOT 2
- Broken when using with typescript and "moduleResolution": "bundler" HOT 3
- Can I copy the payload in the change handler? HOT 5
- pathsOf filter is misbehaving HOT 1
- Unable to get regexp from observable HOT 5
- Un-cure native objects unless proven needed HOT 1
- [ci/cd] remove custom CI logic in favor of standard npm version HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from object-observer.