From 0e7822160454101bff40bee26c16b933fc15b45f Mon Sep 17 00:00:00 2001 From: Adam McCrea Date: Wed, 2 May 2012 20:30:45 -0400 Subject: [PATCH] add docs regarding observers and computed properties (ref #774) --- packages/ember-runtime/lib/ext/function.js | 5 ++++- packages/ember-runtime/lib/mixins/observable.js | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/ember-runtime/lib/ext/function.js b/packages/ember-runtime/lib/ext/function.js index ed1d3b1bbff..41095a28d75 100644 --- a/packages/ember-runtime/lib/ext/function.js +++ b/packages/ember-runtime/lib/ext/function.js @@ -51,7 +51,10 @@ if (Ember.EXTEND_PROTOTYPES) { }); Make sure you list these dependencies so Ember.js knows when to update - bindings that connect to a computed property. + bindings that connect to a computed property. Changing a dependency + will not immediately trigger an update of the computed property, but + will instead clear the cache so that it is updated when the next `get` + is called on the property. Note: you will usually want to use `property(...)` with `cacheable()`. diff --git a/packages/ember-runtime/lib/mixins/observable.js b/packages/ember-runtime/lib/mixins/observable.js index 84591997261..ecd960862bc 100644 --- a/packages/ember-runtime/lib/mixins/observable.js +++ b/packages/ember-runtime/lib/mixins/observable.js @@ -61,6 +61,11 @@ var get = Ember.get, set = Ember.set; This will call the `targetAction` method on the `targetObject` to be called whenever the value of the `propertyKey` changes. + Note that if `propertyKey` is a computed property, the observer will be + called when any of the property dependencies are changed, even if the + resulting value of the computed property is unchanged. This is necessary + because computed properties are not computed until `get` is called. + @extends Ember.Mixin */ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ {