Peek & Filter and live records


My backend gathers all data and returns them in the one response. I have these data properly imported into store and I’m using combination of periodically downloading data and using peek functions.

Let assume that I wish to post these data to template:

model: function() {

This model will send all clusters to template and is updated when data in store are updated. Attempt to obtain a single record:

return'book', 'book-id');

If required data are in cache, we are fine. If they are not in cache, the model will not be updated - becase it does not return ‘live array’ like peekAll(). How we will obtain a record that will be updated?

return'book', (item) => { return === 'book-id'})

Live array is returned and we are fine. But store.filter() is deprecated and will be removed (it is possible to use ember-data-filter, now). This is quite simple case, so there should be simplier solution. What is the right way, to do it without using store.filter() ?

Solution proposed on does not work with live records what I need.


The way that I’ve dealt with this is by setting a property to be the result of your live array this.set('liveBooks,'book')) you can create a CP that observes changes to it and use filter() in that CP.

filterBooks: Ember.computed('liveBooks.[]', function(){
    //filter code