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

JSON Load is Mutating my Array at Application Level #993

Closed
jonlachlan opened this issue Feb 12, 2015 · 3 comments
Closed

JSON Load is Mutating my Array at Application Level #993

jonlachlan opened this issue Feb 12, 2015 · 3 comments
Labels
C-bug Category: This is a bug resolved maybe

Comments

@jonlachlan
Copy link

https://github.com/masayuki0812/c3/blob/master/src/data.convert.js#L37-L41
These lines of code are causing me headache because they are mutating my settings array that holds my keys by pushing the x key onto the end of the array. I use this array for filtering my collection in my subscription model, e.g., {key:{$exists:true}} in Mongo. When x is pushed onto this array, my subscription expands to include all documents that have x. (It also seems to push x repeatedely whenever I have a refresh. So I get multiple instances on x on the array.)

To make this snippet of code more immutable, I've changed it to the following (avoiding the .push() part of it.)

if (keys.x) {
  targetKeys = keys.value.concat(keys.x);
  $$.config.data_x = keys.x;
} else {
  targetKeys = keys.value;
}

I'm not exactly sure why or how it's mutating my array, but it sure has been a pain. Please consider committing this change in a future update.

Thanks!

@masayuki0812
Copy link
Member

Thank you for pointing this out. Yeah, you're right, and I think this has been fixed by this commit above. I'll release this fix in the next version 0.4.10 shortly. Thank you.

@masayuki0812 masayuki0812 added C-bug Category: This is a bug resolved maybe labels Mar 10, 2015
@jonlachlan
Copy link
Author

Great, thanks! I will try to test it, probably won't get a chance to until after the release.

@masayuki0812
Copy link
Member

0.4.10 has been released, so let me close at the moment. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug resolved maybe
Projects
None yet
Development

No branches or pull requests

2 participants