-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Batched bindings #760
Comments
One thing to note with this approach — any changes inside |
You've probably caught this already - + if ( 'bar' in changed ) data.bar = changed.bar; dirty = true;
+ if ( 'baz' in changed ) data.baz = changed.baz; dirty = true;
+ if ( dirty ) { |
No, I hadn't 😀 That's what I get for trying to write code and eat breakfast at the same time. Will fix the code so I don't confuse myself later (though it probably has other bugs, such as not initialising bindings where the parent doesn't have a value but the child does). Thanks |
Bindings on components are implemented with
component.observe
. That's convenient enough, but it has an awkward consequence — if you have two bindings, and they both change in the sameset
operation, you end up with two distinct updates. That's obviously somewhat wasteful.Consider this example:
Every time you hit the 'double' button, the app has to update twice.
We could fix this by implementing bindings differently. This is some untested code that probably misses certain important scenarios, but I think something like this is probably on the right lines:
Then, we call
this._bind
inside_set
. Which itself could arguably be improved by checking that values were in fact changed:(Though perhaps the dirty check belongs in
set
and not_set
? Not actually sure.)The text was updated successfully, but these errors were encountered: