react-debounce-input icon indicating copy to clipboard operation
react-debounce-input copied to clipboard

Optional immediate, non-debounced onChange callback

Open flux627 opened this issue 7 years ago • 6 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

flux627 avatar Oct 05 '16 19:10 flux627

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.

nkbt avatar Oct 05 '16 21:10 nkbt

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"?

flux627 avatar Oct 13 '16 21:10 flux627

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

nkbt avatar Oct 13 '16 23:10 nkbt

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

oyeanuj avatar Mar 01 '18 22:03 oyeanuj

Never did, no.

flux627 avatar Mar 02 '18 17:03 flux627

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

CalMlynarczyk avatar Sep 06 '19 17:09 CalMlynarczyk