Skip to content

Commit

Permalink
Merge pull request #14804 from knownasilya/patch-7
Browse files Browse the repository at this point in the history
[DOCS] Tweak addObserver function signature examples
  • Loading branch information
locks authored Jan 12, 2017
2 parents 07b4fc1 + c8367a0 commit e56dcbe
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions packages/ember-runtime/lib/mixins/observable.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,16 @@ export default Mixin.create({
you do not pass a `context` parameter:
```javascript
fooDidChange: function(sender, key, value, rev) { };
export default Ember.Component.extend({
init() {
this._super(...arguments);
this.addObserver('foo', this, 'fooDidChange');
},
fooDidChange(sender, key, value, rev) {
// your code
}
});
```
The sender is the object that changed. The key is the property that
Expand All @@ -364,7 +373,16 @@ export default Mixin.create({
revision like so:
```javascript
fooDidChange: function(sender, key, value, context, rev) { };
export default Ember.Component.extend({
init() {
this._super(...arguments);
this.addObserver('foo', this, 'fooDidChange');
},
fooDidChange(sender, key, value, context, rev) {
// your code
}
});
```
Usually you will not need the value, context or revision parameters at
Expand Down

0 comments on commit e56dcbe

Please sign in to comment.