Guys, I need to perform a search in the database whenever I change the input value, but I only want to do the search if the user stops typing for x seconds. Does anyone know how to do this?
Hi @GregoryRosa
The best practice to do this would be to add a debounce to your search.
You can learn more about this here.
Does that help?
Okay, I understand the reasoning, but when the Debounced variable is updated, I need it to trigger the workflow that fetches data from the database. I tried setting the variable’s value in the ‘init value’ of another input to trigger its onchange event and perform the database search, but changing the input’s ‘init value’ doesn’t trigger its onchange event.
Not sure what you mean. If you setup the debounce on the search input, you can trigger the workflow on change and use the variable with delay to tell the database what search term you’re looking for.
Can you show us a video or screenshots of how you set things up on your side and where the behavior isn’t what you’d like it to be?
I managed to do it, actually just by adding a delay to the input I’m typing in and using onchange. The onchange only executes after this delay, so there’s no need for an auxiliary variable