Created
June 5, 2018 10:24
-
-
Save RecoX/8c80d6aaa6f07a1e5f418480315cdf7b to your computer and use it in GitHub Desktop.
Observer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
myService: Ember.inject.service('my-service'), | |
appName: 'Ember Twiddle', | |
init() { | |
this.get('myService'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Service.extend({ | |
init() { | |
this._super(...arguments); | |
console.log(123, this); | |
this.set('foo', 'bar'); | |
this.set('bar', 'foo'); | |
this.addObserver('foo', this , 'fooDidChange'); | |
}, | |
fooDidChange(sender, key, value, rev) { | |
console.log(sender, key); | |
// your code | |
console.log('1'); | |
},}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.14.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "2.18.2", | |
"ember-template-compiler": "2.18.2", | |
"ember-testing": "2.18.2" | |
}, | |
"addons": { | |
"ember-data": "2.18.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment