Don't stringify and parse the error object to and from json#22
Conversation
Stringifying and parsing again will throw when `obj` has a circular structure which can exist when e.g. ember data relationships are values in the changesets underlying object. Fixes adopted-ember-addons#19
|
Just putting down my thoughts. This might be the right way to go. At one point, I remember I needed to avoid some consumer mutating it so I wanted to return a unique object every time. Do you think there might be an alternate solution as well? |
|
@snewcomer 🤔 so the point was to create a copied object of the value to avoid mutation? Well I kind of like the idea but the thing is I didn't even expected that value reference to be immutable and its also not (yet) mentioned in the readme. On the other hand I'm unsure if we actually want to copy that value on every Regarding an alternative solution, I could imagine having something like a lightweight proxy that basically makes the value properties read only, i.e. a proxy that does nothing on const handler = {
get(obj, prop) {
return typeof obj[prop] === 'object' ? new Proxy(obj[prop], handler) : obj[prop];
},
set() {}
};and then in const value = new Proxy(theValue, handler);I'd suggest to address that topic in a new issue though. Currently the visible and inevitable problem is that because of |
|
@ohcibi There is one thing we need to do before we merge as it will break tests in ember-changeset - convert it from the |
|
We will just update ember-changest to be compatible. Thanks for the PR! |
Stringifying and parsing again will throw when
objhas a circularstructure which can exist when e.g. ember data relationships are values
in the changesets underlying object. Fixes #19