In our project, there's sometime a delay for some data to be provided, in the case fileUrl
.
What method in Ember
can I use to periodically check that a property has been filled with a value. Then when it's filled, stop the periodic check?
JS (Ember):
import Ember from 'ember';
export default Ember.Controller.extend( {
licences: Ember.A([
'Asia',
'EU',
'USA'
]),
experimentLicence: 'Asia',
actions: {
selectLicence(licence) {
this.set('experimentLicence', licence);
},
saveDataset(model) {
model.set('licence', this.get('experimentLicence'));
model.save()
.then(() => {
this.send('hideModal');
/**
* periodically check if file url is ready to be used
* Then when file url is ready stop the periodic check
*/
Ember.run.debouce(() => {
// check if file url is ready
if (model.get('fileUrl')) {
this.send('datasetsIsExportedToMendeleyData', model);
}
});
})
.catch(() => {
console.log('Oops! Something went wrong. We\'ll fix it as soon as possible.');
});
},
cancel() {
this.send('hideModal');
},
}
});
Aucun commentaire:
Enregistrer un commentaire