mercredi 25 mai 2016

Reloading just one model using RSVP in Ember

To load many data models into a route on the model hook you need to use RSVP so I'm doing this:

export default Ember.Route.extend( {
  model( params ) {
    return Ember.RSVP.hash( {
      cars: this.store.query( "car", params ),
      stats: this.store.findRecord( "shop", 1 ),
    } );
  }
} );

The problem comes in that stats is always going to be the same but using queryParams I will change the cars list. Setting queryParams as:

queryParams: {
  color: {
    refreshModel: true,
  },
}

will call the model hook (as intended) but it will reload both models, cars and stats, when I'm only interested in refreshing cars.

Is there a way, with or without RSVP, to load both models on entry but only update one of them when queryParams change?




Aucun commentaire:

Enregistrer un commentaire