nkbt / react-debounce-input

React component that renders Input with debounced onChange
MIT License
451 stars 61 forks source link

Optional immediate, non-debounced onChange callback #55

Open flux627 opened 8 years ago

flux627 commented 8 years ago

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

nkbt commented 8 years ago

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.

flux627 commented 8 years ago

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

nkbt commented 8 years ago

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

oyeanuj commented 6 years ago

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

flux627 commented 6 years ago

Never did, no.

CalMlynarczyk commented 5 years ago

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