nkbt / react-debounce-input

React component that renders Input with debounced onChange

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Optional immediate, non-debounced onChange callback

flux627 opened this issue · comments

It would be nice to trigger loading indicators as soon as they start typing, to have the user feel like it's doing something, without the lag of the debounce. It could be called "immediateOnChange".

Any suggestions on how to do this without any modifications to react-debounce-input would also be appreciated

Interesting suggestion. I don't think you can do this now without code modifications. Are you keen to PR? I believe it would be nice addition.

I was thinking of making this possibly more useful with an "onDebounceStart", so it only fires once when the debounce timeout starts, rather than every time the input changes. I can see value in both this and an "immediateOnChange" event, however I'm not in love with that name. Maybe "onEveryChange"?

onEveryChange sounds ok to me, also keeps onX convention for callbacks

commented

@flux627 Did you ever making this happen in any branch or PR by any chance?

Never did, no.

We were able to accomplish this by wrapping an input component and directly invoking the onChange handler that came from DebounceInput, as well as an immediate onChange handler that we wanted. We wanted to split cheap (ex. writing to Redux) and expensive (ex. sending the input in an AJAX request) event handlers so we could debounce the expensive ones.

Codepen