Using debounce on input

Under most circumstances I would use a text input field with an on-input or on-updated event to fire a server action, this allows me to use a debounce parameter to stop the script running on every keystroke.

In this particular case I have a server action with many dmx-param checks linked to the textinput.value of the field I want to check. Is there a way to add a debounce still?

Here are some examples

<!--Normal way, with debounce-->
<input dmx-on:updated.debounce:300="sc1.load(what_input: value)" id="searchTextName" name="searchTextName" type="text">

<!--Secondary Way, how to add debounce?-->
<dmx-serverconnect id="sc1" url="api/image-list" dmx-param:what_input="searchTextName.value"></dmx-serverconnect>

<input id="searchTextName" name="searchTextName" type="text">

How I have configured this in the past:

  1. INPUT field where user enters value. This has debounce on input/changed/updated event.
  2. On the event, it just updates value of another variable, say varInputCopy.
  3. In SC, bind the param with varInputCopy instead of the input field.
3 Likes

Ahhh, good plan, thanks Sid, didn’t even think about trying that, but that sounds like a good solution.