Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deepstream not updating object properties #96

Closed
charles-toller opened this issue Apr 23, 2016 · 4 comments
Closed

Deepstream not updating object properties #96

charles-toller opened this issue Apr 23, 2016 · 4 comments

Comments

@charles-toller
Copy link
Contributor

Deepstream will not push an update to subscribers of a record if that record is an object which has a property that changes. Offending code:
var myObject = {hello:1};
ds.record.getRecord('myRecord').set('mySubrecord',myObject);
//mySubrecord on this client returns {hello:1}, other clients {hello:1}
myObject.hello = 2;
//mySubrecord on this client returns {hello:1}, other clients {hello:1}
ds.record.getRecord('myRecord').set('mySubrecord',myObject);
//mySubrecord on this client returns {hello:2}, other clients {hello:1}
This is specifically happening using the node.js client at 0.5.0, node.js version 5.11.0, and node.js server at 0.9.0.

@charles-toller
Copy link
Contributor Author

Forgot to mention, if you change the last line to:
ds.record.getRecord('myRecord').set('mySubrecord',Object.assign({},myObject))
It works flawlessly.

@WolframHempel
Copy link
Member

Could I ask you to make sure you're using the latest version of the client library? This should have been fixed in release 0.4.2

@charles-toller
Copy link
Contributor Author

Running client 0.5.0.

@charles-toller
Copy link
Contributor Author

Found it. JSONPath sets its value at https://github.com/deepstreamIO/deepstream.io-client-js/blob/master/src/record/json-path.js#L70. This set is by reference, so when an object property changes, the local copy of the record is updated, but connection.sendMessage is not called. Then, if you manually set the record, it shows as unmodified (https://github.com/deepstreamIO/deepstream.io-client-js/blob/master/src/record/record.js#L102) so connection.sendMessage is still not called.

I don't know what the best solution is, but maybe a force update or copy on set would work.

charles-toller added a commit to charles-toller/deepstream.io-client-js that referenced this issue Apr 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants