You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Observer on computed property is firing when the computed value is unchanged #774
When "set" is called on the "prop" property, the observer only fires if it is set with a new value. This is expected behavior.
The "computedProp" observer is firing every time, though, even when the computed value is the same. I believe this is unexpected behavior. The value is being recalculated because one of it's dependencies changes, but I think the observer should only fire if the actual value changes.
@adamlogic There's no way around it. We don't compute CPs until get is called, which happens after the observer is fired. If we checked right away, we'd have to compute much more frequently and performance would suffer.
@adamlogic Certainly. It would definitely be worth highlighting the fact that CPs are lazily computed. It's totally worth it, but sometimes it catches people by surprise, especially if they are trying to use CPs when they should use observers.
I once saw someone trying to do responsive style behavior in a CP, definitely an odd idea. The main thing you'll notice is that observers fire instantly, whereas bindings wait until the end of the runloop and CPs don't fire until requested.
Activity
wagenet commentedon May 2, 2012
@adamlogic There's no way around it. We don't compute CPs until
getis called, which happens after the observer is fired. If we checked right away, we'd have to compute much more frequently and performance would suffer.adamlogic commentedon May 2, 2012
@wagenet Understood. Would you be open to a docs patch that clarifies this behavior?
wagenet commentedon May 2, 2012
@adamlogic Certainly. It would definitely be worth highlighting the fact that CPs are lazily computed. It's totally worth it, but sometimes it catches people by surprise, especially if they are trying to use CPs when they should use observers.
adamlogic commentedon May 3, 2012
@wagenet Added a pull request. Curious if you have any examples handy of people using CPs when they should use observers.
wagenet commentedon May 3, 2012
I once saw someone trying to do responsive style behavior in a CP, definitely an odd idea. The main thing you'll notice is that observers fire instantly, whereas bindings wait until the end of the runloop and CPs don't fire until requested.
add docs regarding observers and computed properties (ref emberjs#774)
Merge pull request #780 from adamlogic/computed_property_observers
Add an optional feature "no-implicit-route-model" to allow opting into
[FEATURE] Add an optional feature "no-implicit-route-model" to allow …
Merge pull request #20639 from emberjs/kg-add-deprecation-optional-fe…
[FEATURE] Add an optional feature "no-implicit-route-model" to allow …