I have this code:
new Ember.RSVP.Promise((resolve) => {
let promise = myList.pushObject(book);
resolve(promise);
}).then(() => {
this.send('scrollToBottom', '#myList');
});
Is there a better way of doing it?
I have this code:
new Ember.RSVP.Promise((resolve) => {
let promise = myList.pushObject(book);
resolve(promise);
}).then(() => {
this.send('scrollToBottom', '#myList');
});
Is there a better way of doing it?
yes:
myList.pushObject(book);
Ember.run.schedule('afterRender', this, 'send', 'scrollToBottom', '#myList');
The promise code is not doing anything except happening to be async. It may or may not pause long enough to allow rendering. Instead, use the runloop to do stuff at the right time.
RSVP Promise resolves in the same run loop. So it’s not really async anyway.
@lightblade is this an aswer to me?