Slide 58
Slide 58 text
WAITING FOR ASYNCHRONOUS OPERATIONS
TESTING ASYNC USER INTERACTIONS
import Component from '@ember/component';
import { debounce } from '@ember/runloop';
export default Component.extend({
pull: null,
comments: null,
loadComments(pull) {
const commentsUrl = pull.get('commentsUrl');
return this.get(‘request’).fetch(commentsUrl).then((comments) => {
this.set('comments', comments);
this.set('isLoadingComments', false);
});
},
actions: {
loadComments(pull) {
this.set('isLoadingComments', true);
debounce(this, this.loadComments, pull, 800);
},
},
});