mardi 2 juin 2015

Prevent server call when model is already loaded and won't change

I have a route which makes server calls for 2 models. There is one of those model which isn't gonna change when someones uses the app. The problem I have is that ember keeps making server calls to fill the subuser model (which doesn't change) when I need to update the conversations model.

What is the best way to prevent that? I am using the method findAll to retrieve datas for the subusers model.

Server calls to subuser are made everytime I filter the conversations model :

http://ift.tt/1M0IEJw

Here is my router :

App.Router.map(function(){

//Routing list to raw namespace path
    this.resource('conversations', { path : '/' }, function() {
    this.resource('conversation', { path : '/:conversation_id'});
    });

});

Here is my route :

App.ConversationsRoute = Ember.Route.extend({

model: function(params){

        return this.store.find('conversation', { status : params.status});
},

setupController: function(controller, model){

    this._super(controller.model);

    controller.set('subusers', this.store.findAll('subuser'));
},

queryParams: {
    status: {
        refreshModel: true
    }
}
});




Aucun commentaire:

Enregistrer un commentaire