Typeahead library issue https://twitter.imtqy.com/typeahead.js/
Since the case here is simple, I can use a quick and dirty solution:
onChange: (event) -> if @_timeoutTask? clearTimeout @_timeoutTask @_timeoutTask = setTimeout (=> @sendToParent event.target.value clearTimeout @_timeoutTask ), 5000
Thus, the task will be initiated 5 seconds after entering. If a new event occurs, the old task will be canceled and a new task will be scheduled, and then another 5 seconds of waiting.
The reagent difference is where the state of the calculation is stored, such as _timeoutTask
. File scope, component state, or component instance.
Since _timeoutTask
is a component level, it must be stored globally. And this does not affect the rendering, therefore it is not able to component either. Therefore, I suggest directly linking it to the component instance.
source share