Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

karlguillotte/ember-searchable-array

Repository files navigation

Ember Searchable Array

This Ember addon provides an Ember.Mixin to facilitate text search using Sifter in array proxies. It can be added to any Ember.ArrayProxy or Ember.ArrayController to enable search on it. A dummy application has been created to showcase this Mixin. See Running section for more details.

This README outlines the details of using and collaborating on this Ember addon.

Usage

export default Ember.ArrayController.extend(SearchableArray, {
	queryParams: ['term'],
	term: '',
	searchProperties: ['name', 'description'],
	searchTerm: Ember.computed.alias('term')
});

The ArrayController above exposes a property searchedContent that will be changed as soon as the value of searchTerm change. searchProperties is a concatenatedProperties that contains keys of properties participating in the search. The Mixin exposes a property searchResult that expose the result of the search. Please refer to Sifter repository for more details and on the tests or the dummy application for more usage information.

Sometimes, it might be a good idea to debounce the search process. Here is an example how this can be achieve.

export default Ember.ArrayController.extend(SearchableArray, {
	queryParams: ['term'],
	term: '',
	searchProperties: ['name', 'description'],
	setSearchTerm: function() {
		Ember.run.debounce(this, this.set, 'searchTerm', this.get('term'), 150);
	}.observes('term')
});

Installation

  • git clone this repository
  • npm install
  • bower install

Running

Running Tests

  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.

About

Array Proxy Mixin to facilitate text search using Sifter.

Resources

Stars

Watchers

Forks

Packages

No packages published