johno / ember-list-filter

List filtering component with a text input.
MIT License
2 stars 0 forks source link

List filter is slow on huge data sets. #2

Open johno opened 9 years ago

johno commented 9 years ago

Add a single property component that can be more performant:

  filteredList: function() {
    var query = this.get('filterQuery').trim();
    var strictMatch = this.get('strictMatch');

    if (Ember.isBlank(query)) {
      return this.get('list');
    }

    if (!strictMatch) {
      query = query.toLowerCase();
    }

    return this.get('list').filter(function(object) {
      if (strictMatch) {
        if (Ember.isEqual(object.get('name'))) {
          return true;
        }
      } else {
        if (isLike(object.get('name').toLowerCase(), query)) {
          return true;
        }
      }
    });
  }.property('list.@each.name', 'filterQuery')
johno commented 9 years ago

Also, leverage Ember.computed: https://medium.com/the-ember-way/ember-simple-text-search-computed-property-macro-1b7ca6a25ad2