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
two-way binding on variable with setter causes initial call to setter #258
Comments
Hmm, this might be more of an issue with the design on my part. It seems that even if I short circuit the initial |
Changing I don't believe it should behave that way, but I have been wrong before haha |
@CasiOo yeah I'm hoping this is indeed a bug, it would save me some refactoring time 😄 |
I've updated plunker with a button on the top to change the |
@jdanyow Can you look into this or comment? |
The controller I wonder if we should remove the |
@jdanyow the last sentence sounds like a decent proposal, would that potentially break other expected behaviors? |
A bindable has a particular behavior as part of the binding cycle of a component:
|
@jdanyow Are you suggesting to have a second implemention, similar to |
I'm not sure that would work...when would the subscribers be notified? Consider one component that binds to another component's property. That subscriber needs to be notified of the initial value. |
@EisenbergEffect so you're saying the way to avoid the "initial bind" behavior is to implement
so that I can use the VM as a parent for a sub-dialog |
@EisenbergEffect makes sense, so I guess we have no choice but to evaluate the source expression and compare it to the new value. this.updateSource(newValue); Would become: if (this.sourceExpression.evaluate(...) !== newValue) {
this.updateSource(newValue);
} sound good? |
What do you think would be the impact of that? It's only going to affect two-way bindings correct? So, that shouldn't be a perf issue. Am I following correctly? |
right- two-way bindings only, shouldn't be an issue. |
ok, sounds good |
I have a pretty involved grid component that uses two-way binding to (among other things) control pagination and sort order data. For sort order, I have a number of
grid-column-header
elements which two-way bind to anorder
variable, and toggle it based on click of that header: works fantastically. What I am not noticing (and hadn't in previous versions) is that on the initial display, each of the individual column headers is causing aset
on theorder
variable which is of course leading my code to update the entire table N times (N === number of columns). Is there any way to avoid this behavior?relevant example: http://plnkr.co/edit/3tsFCI0xG30QHYU6rsPt
note that when you start the example you have 20 console.log statements for
sharedValue set
The text was updated successfully, but these errors were encountered: