Przeglądaj źródła

Debounce/Throttling Searching event

New backend call to each keydown may hit the back-end performance.
500ms is reasonable delay to avoid too many requests while user is
typing a search query
Anatoly Mikhailov 11 lat temu
rodzic
commit
6abad666db
1 zmienionych plików z 1 dodań i 1 usunięć
  1. 1 1
      src/app/partials/search.html

+ 1 - 1
src/app/partials/search.html

@@ -22,7 +22,7 @@
 				</button>
 				</button>
 				<span style="position: relative;">
 				<span style="position: relative;">
 					<input  type="text" placeholder="search dashboards, metrics, or graphs" xng-focus="giveSearchFocus"
 					<input  type="text" placeholder="search dashboards, metrics, or graphs" xng-focus="giveSearchFocus"
-									ng-keydown="keyDown($event)" ng-model="query.query" spellcheck='false' ng-change="search()" />
+									ng-keydown="keyDown($event)" ng-model="query.query" ng-model-options="{ debounce: 500 }" spellcheck='false' ng-change="search()" />
 					<a class="search-tagview-switch" href="javascript:void(0);" ng-class="{'active': tagsOnly}" ng-click="showTags($event)">tags</a>
 					<a class="search-tagview-switch" href="javascript:void(0);" ng-class="{'active': tagsOnly}" ng-click="showTags($event)">tags</a>
 				</span>
 				</span>
 			</div>
 			</div>