Skip to content

Commit 5203d64

Browse files
committed
Adding docs for require-dks
1 parent 4905ff1 commit 5203d64

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Require Dependent Keys
2+
3+
One can think of computed properties as cached accessors, that broadcast change events if consumed, and their dependent key has changed. In-general computed properties that do not mutate state, will just do the right thing. They will be on-demand, and data will flow nicely.
4+
5+
```
6+
export default Ember.Component.extend({
7+
fullName: Ember.computed('first', 'last', function() {
8+
return this.get('first') + ' ' + this.get('last');
9+
});
10+
});
11+
```
12+
13+
However, for computed properties to work correctly they must enumerate their dependencies. If they do not enumerate their dependencies you run the risk of the CP cache being stale or eagerly computed. This rule makes sure that when you use a computed property it has dependent keys.

0 commit comments

Comments
 (0)