mardi 24 mars 2015

[emberjs]what's point of adding 'on("init")' to observabes?

I'm learning ember-cli-101. It adds on('init') when using observer. I tried to delete it , and it makes no difference. I tried to read the api document and still make no sense, please help me out...



stateChanged: function() {
var article = this.get('article');

if (article.get('isDirty') && !article.get('isSaving')) {
Ember.run.once(this, this.autoSave);
}
}.on('init').observes('article.state')

stateChanged: function() {
var article = this.get('article');

if (article.get('isDirty') && !article.get('isSaving')) {
Ember.run.once(this, this.autoSave);
}
}.observes('article.state')


They really works the same, what's the difference...





Aucun commentaire:

Enregistrer un commentaire