-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
getters/setters are executed against the original model, not the modified one #161
Comments
This looks like a valid bug. Looking into it! Thx for submitting! |
@azhiv you have presented us with quite an interesting problem! The reason is because you are getting the "not yet" applied value. The question is, if you haven't called Where we return the "change" instead of |
@snewcomer I don't see a way forward here unless you build/obtain an object that represents the current state of the amended entity. const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(target), prop);
if (descriptor) {
// method is either 'get' or 'set'
const descriptorMethod = descriptor[method];
if (!descriptor.enumerable && descriptorMethod) {
// It is a corresponding method defined on the model. We invoke with this=Proxy
// In this way it is evaluated with all changes applied to ChangeBuffer in place.
return descriptorMethod.call(receiver, value),
... |
@azhiv I don't see one either :(. If we execute the get, we may change state, which would be unintentional and against the paradigm of a changeset - to avoid mutations until you want them. |
Consider the following class:
If you create a change buffer over an instance of this class and modify it:
the results are a bit unexpected. Would you consider getting the property descriptor
and then executing it against the change buffer instance?
The text was updated successfully, but these errors were encountered: