-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
Hi,
I am trying to do some debouncing in quiescent, and it turns out more complicated than expected. I am aiming to have something like this:
(d/input {:value search-text :onChange #(let [newval (.. % -target -value)]
(debounce (fn []
(swap! app-state assoc :search-text newval)
(do-search newval))
500))})The effect should be that the search should happen only after the user stops typing (i.e. didn't type anything in the last 500 ms).
There are two problems here:
- Multiple calls of a debounced function need a shared timer value, so the above won't work. The timer value needs to be outside of the input, so it can't be constructed by
debounce. - But more worse is that in quiescent components are always rebuilt at rerendering, which means that the shared timer needs to be outside the component as well, which I find a weird thing to do.
Do you have a better idea how to solve this in quiescent?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels