lundi 8 mai 2017

Does refreshing async model refreshes the promise returned?

I'm trying to display a loading substate when my app is fetching data after a certain query param, in this case, number, is changed. I notice the loading substate only gets displayed the first time number gets changed.

Here's the model:

export default DS.Model.extend({
  number: DS.attr('string'),
  items: DS.hasMany('item', { async: true }),
});

The route:

export default Ember.Route.extend(AuthenticatedRouteMixin, RouteMixin, {

 queryParams: {
  number: {
   refreshModel: true
  }
 },

 model(params) {
  if (params.number.length != 0){
   return this.store.queryRecord('page', params);
  }
 },
});

The template:


  <div></div> // this component depends on number

 


Even though my model refreshes every time I change it, I notice the loading-substate only gets triggered the first time I change it.




Aucun commentaire:

Enregistrer un commentaire