[deprecations] Remove the need to use beforeObserver in job-log component
This commit is contained in:
parent
21f25cd2bf
commit
13d2eba016
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user