I want to know when all content has rendered the first time, but Ember.run.scheduleOnce('afterRender'
isn't enough because there are promises in the template.
{{#each entity in model.entities}}
{{entity.anotherEntity.name}}
{{/each}}
{{!-- more like above --}}
Where entities
and anotherEntities
are async relationships and promises. The afterRender
hits before that inner content has rendered. My current solution is:
Ember.run.scheduleOnce('afterRender', this, function() {
Ember.RSVP.all([
this.model.get('entities').then(function(entities) {
return Ember.RSVP.all(entities.map(function(entity) {
return entity.get('anotherEntity');
}));
}),
// more like above
]).then(function() {
console.log('done-rendering');
});
});
Is there a better way to do it? This might not even be enough because there could be a split second between when the last promise resolves and the last section of template renders. Maybe I need another afterRender
or similar check after all the promises resolve to be sure.