Debounce on input so map address lookup doesn't happen with every keystroke

I’m struggling to find the debounce option, I know it’s there somewhere!

I have an input box where the value is used on a Google Map Address attribute but, to keep the API charges as low as possible, I don’t want it to look up after every keystroke so I’m thinking the debounce option is the way to go but I can’t find it anywhere. Can any point me in the right direction?

The syntax for applying debounce is:

dmx-on:updated.debounce:300

You usually find it below the action input field of an event. If its not there, you can write it out and see if it works.

Thanks @sid. I knew it was there somewhere! It turns out not to be the solution I was hoping for as it only debounces the action whereas I have my map set to get the address from the input value so I’m now looking at the address autocomplete option instead. That would actually be a better solution anyway.

I am not sure I totally follow, but if the user is typing in the address, putting debounce on updated event should delay the execution of action - which is making API call. Is that not what needs to happen here?

No. There isn’t an action on the input field. I have set the map address to get the value from the input directly which might not be the best approach. I can’t find a way of setting the map address using an action on the input field which is why I did it the way I did.

Ah. Now I follow.
Here's a dirty fix...

  1. Create a variable.
  2. Set map address to get value from variable.
  3. On debounced input action, update the variable value.

A better fix would be to invoke the map address on input action, if possible.

1 Like