mercredi 23 mars 2016

Ember data cache and update query result

In my app I need to cache the result of a query:

model: function(params, transition) {
    if (!App.Registry.modelLoaded.feed) {
        App.Registry.modelLoaded.feed = true;

        return this.store.query('photo', {type: 'feed'});

    }
    else {
        // peek already fetched photos that are flagged to be in feed
        return this.store.peekAll('photo').filterBy('isInFeed').filterBy('isDeleted', false);
    }
}

that works, but now I also would like to add a background call that loads again the query results from the server while the client is already showing the peeked records, check if some of them is new, add the new ones to the current model and reactively update the template;

so the result I would like to achieve is to mimic what ember-data is normally supposed to do with a findAll();




Aucun commentaire:

Enregistrer un commentaire