Skip to content

add failing test case for #111 #112

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

smhg
Copy link
Contributor

@smhg smhg commented Jun 22, 2017

Similar to the example in #111.
Maybe it is nice to also test whether the the original value and the final value don't refer to the same object? To make sure the set happened (since the value was actually changed more or less).

@smhg smhg changed the title add failing test case for #111 prevent update when changes are reset #111 Sep 30, 2017
src/cortex.js Outdated
@@ -44,9 +44,29 @@ module.exports = (function() {
}
}

__remove(path) {
for(var i = 0, ii = this.__diffs.length; i < ii; i++) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow the logic here. It's a little inefficient with O(n^2). It seems the simplest solution is to just compare the initial and final state. If they're the same the rollback/cancel the update

Copy link
Contributor Author

@smhg smhg Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean loop once through all queued diffs in this._diffs comparing them to this.__value?
If so, you mean here inside the __remove() event handler, right?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using diffs, it’s probably better to let the update runs its course and as a final check perform a deep comparison between final and initial values (they’re immutable so already separate objects). If they’re the same then don’t run the callbacks.

@smhg smhg force-pushed the issue-revert-change branch from 23268ac to e80e805 Compare February 20, 2018 10:20
@smhg smhg changed the title prevent update when changes are reset #111 add failing test case for #111 Feb 20, 2018
@smhg
Copy link
Contributor Author

smhg commented Feb 20, 2018

I've removed the possible fix from this PR as it took the wrong route (see #111).
But I hope the failing test is important enough to merge?

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

Successfully merging this pull request may close these issues.

2 participants