Unconsumed computed properties do not trigger observers


#1

On the Ember Guides In the section Object Model - Observers it is stated that:

If you never get a computed property, its observers will not fire even if its dependent keys change. You can think of the value changing from one unknown value to another.

This doesn’t make any sense to me, can someone explain what it means?

A set will fire the observor, but a get?

Also what does unconsumed mean in this context?


#2

It’s a performance thing, if nothing want’s the computed property value, then why compute it… So if nothing in JavaScript .get('foobar'), used in another computed property as a dependent key, used in a template {{foobar}}, used in a helper {{ucwords foobar}}, etc. need the computed property, then it won’t be computed. That would be the unconsumed context.

Both .set() and .get() will obviously trigger the computed property. However, if you don’t return anything when you .set() then nothing will be cached and the computed property will remain unconsumed (if previously unconsumed).


#3

Alright thanks, I get it now (what I suspected it meant but wasn’t sure).

It’s a caching mechanism which only gets consumed/triggered when needed.

Perhaps a slight rewrite would clarify things up for newbies.


#4

I believe a guide and api update/rewrite is coming with Ember 2.0. :smile:


#5

Any idea where this update is available? Would sure be eager to have a sneak preview!