github.com/emate/nomad@v0.8.2-wo-binpacking/ui/app/components/search-box.js (about)

     1  import { reads } from '@ember/object/computed';
     2  import Component from '@ember/component';
     3  import { run } from '@ember/runloop';
     4  
     5  export default Component.extend({
     6    // Passed to the component (mutable)
     7    searchTerm: null,
     8  
     9    // Used as a debounce buffer
    10    _searchTerm: 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  }