How to achieve key down "laziness" or Lazy Search

There are use cases when you need to do some calculations or send a request to get data as the user types in the input. It can be either a simple search in a table with a given condition taken from the input, or more complex use cases. However, along with the desire to get the result as the user types the text, we would like to avoid unnecessary requests. For this, the algorithm of actions can be as follows:

  • While the user is typing, we schedule a request that will be sent in 1 second;
  • If after one second the user continues typing, cancel the previous request and schedule a new one (and so on in a circle while the user continues typing);
  • If after one second the user has not typed anything, send the scheduled request.

And here’s how it can be implemented using codeless:

That’s it!