github.com/blixtra/nomad@v0.7.2-0.20171221000451-da9a1d7bb050/ui/app/components/search-box.js (about) 1 import Ember from 'ember'; 2 3 const { Component, computed, run } = Ember; 4 5 export default Component.extend({ 6 // Passed to the component (mutable) 7 searchTerm: null, 8 9 // Used as a debounce buffer 10 _searchTerm: computed.reads('searchTerm'), 11 12 // Used to throttle sets to searchTerm 13 debounce: 150, 14 15 classNames: ['search-box', 'field', 'has-addons'], 16 17 actions: { 18 setSearchTerm(e) { 19 this.set('_searchTerm', e.target.value); 20 run.debounce(this, updateSearch, this.get('debounce')); 21 }, 22 }, 23 }); 24 25 function updateSearch() { 26 this.set('searchTerm', this.get('_searchTerm')); 27 }