
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
ember-data-live-filter-by
Advanced tools
ember install ember-data-live-filter-by
Ember Data Live FilterBy adds an options argument to the filterBy method on DS.RecordArrays (the object returned from store.peekAll) and DS.ManyArrays (the object used to hold DS.hasMany relationships). When { live: true } is passed as the options parameter to filterBy it will return a live array that will update whenever a record is added, removed or updated in the original array. If the options argument is not provided, or the live property is falsy then filterBy will return a normal array.
App.PostController = Ember.Controller.extend({
allPosts: function() {
return this.store.peekAll('post');
}.property()
allUndeletedPosts: function() {
return this.store.peekAll('post').filterBy('isDeleted', false, { live: true });
}.property()
});
App.Post = Ember.Model.extend({
comments: DS.hasMany('comment'),
undeletedComments: function() {
return this.get('comments').filterBy('isDeleted', false, { live: true });
}.property()
});
Durring the Ember Data 1.0.0 betas and in the Ember Data 1.13 release. Records that were marked as deleted locally but not yet saved to the backend were automatically removed from the RecordArrays returned by store.peekAll('type') and the ManyArrays returned by hasMany relationships. In Ember Data 2.0.0 records are not removed from these arrays until they have acknowledged as deleted by the backend. This plugin makes it easier to transition old code from Ember Data 1.13 to work with Ember Data 2.0.
You can combine store.peekAll or a hasMany relationship with a computed property to acheive the same functionality:
// app/controllers/posts.js
export default Ember.Controller.extend({
posts: Ember.computed(function() {
return this.store.peekAll('post');
}),
filteredPosts: Ember.computed('posts.@each.isPublished', function() {
return this.get('posts').filterBy('isPublished');
})
});
// app/models/post.js
export default DS.Model.extend({
comments: DS.hasMany('comment'),
maintainedComments: Ember.computed('comments.@each.isDeleted', function() {
return this.get('comments').filterBy('isDeleted', false);
})
});
git clone this repositorynpm installbower installember serverember testember test --serverember buildFor more information on using ember-cli, visit http://www.ember-cli.com/.
FAQs
The default blueprint for ember-cli addons.
We found that ember-data-live-filter-by demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.