[deprecations] Remove the need to use beforeObserver in job-log component

This commit is contained in:
Piotr Sarnacki 2016-01-12 18:26:10 +01:00
parent 21f25cd2bf
commit 13d2eba016

View File

@ -3,36 +3,24 @@ import Ember from 'ember';
export default Ember.Component.extend({
logBinding: 'job.log',
didInsertElement() {
Ember.run.scheduleOnce('afterRender', this, 'setupLog');
},
didReceiveAttrs: function(options) {
this._super(...arguments);
logDidChange: function() {
return this.setupLog();
}.observes('log'),
if(options.oldAttrs && options.oldAttrs.job) {
this.teardownLog(options.oldAttrs.job.value);
}
logWillChange: function() {
return this.teardownLog();
}.observesBefore('log'),
willDestroyElement() {
Ember.run.scheduleOnce('afterRender', this, 'teardownLog');
},
teardownLog() {
var job;
job = this.get('job');
if (job) {
return job.unsubscribe();
if(options.newAttrs && options.newAttrs.job) {
this.setupLog(options.newAttrs.job.value);
}
},
setupLog() {
var job;
job = this.get('job');
if (job) {
job.get('log').fetch();
return job.subscribe();
}
teardownLog(job) {
job.unsubscribe();
},
setupLog(job) {
job.get('log').fetch();
job.subscribe();
}
});