docs: update, re-added debounce
This commit is contained in:
		
							parent
							
								
									b10b23a47b
								
							
						
					
					
						commit
						8fc6b8e28e
					
				
					 2 changed files with 11 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -15,7 +15,15 @@ async function searchContents(query) {
 | 
			
		|||
  return (await response.json());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
registerHandlers((e) => {
 | 
			
		||||
function debounce(func, timeout = 200) {
 | 
			
		||||
  let timer;
 | 
			
		||||
  return (...args) => {
 | 
			
		||||
    clearTimeout(timer)
 | 
			
		||||
    timer = setTimeout(() => { func.apply(this, args); }, timeout)
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
registerHandlers(debounce((e) => {
 | 
			
		||||
  term = e.target.value
 | 
			
		||||
  if (term !== "") {
 | 
			
		||||
    searchContents(term)
 | 
			
		||||
| 
						 | 
				
			
			@ -27,4 +35,4 @@ registerHandlers((e) => {
 | 
			
		|||
      ))
 | 
			
		||||
      .then(results => displayResults(results))
 | 
			
		||||
  }
 | 
			
		||||
})
 | 
			
		||||
}))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue