我有以下输入:
<input type="text" placeholder="Search for new results" (input)="constructNewGrid($event)" (keydown.backslash)="constructNewGrid($event)">
Run Code Online (Sandbox Code Playgroud)
和功能
constructNewGrid(e){
// I want to wait 300ms after the last keystroke before constructing the new grid
// If the passed time is <300ms just return without doing something
// else start constructing new grid
}
Run Code Online (Sandbox Code Playgroud)
我不太确定如何建立这样的条件。我应该如何解决这个问题?我在 RxJS 中阅读了关于 debounceTime 的内容,这正是我想要的,但我没有在函数中使用 observable,所以:你将如何在函数中构建这样的条件?