Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boolean indicating if debounced is queued or not #2618

Closed
thenewguy opened this issue Aug 31, 2016 · 3 comments
Closed

boolean indicating if debounced is queued or not #2618

thenewguy opened this issue Aug 31, 2016 · 3 comments

Comments

@thenewguy
Copy link

It would be nice if the debounced function wrapper exposed if function execution is pending

Example use case: Search input and submit button. The search input automatically submits onChange using the lodash debounce utility. The submit button should be disabled unless there is a debounced onChange call. Something like debouncedFoo.pending or debouncedFoo.isPending() would make this simple

@thenewguy
Copy link
Author

thenewguy commented Aug 31, 2016

this seems to do the trick:

  debounced.isPending = function(){return timerId !== undefined};

@jdalton
Copy link
Member

jdalton commented Aug 31, 2016

Thanks @thenewguy!

We'll keep an eye on the popularity of the request.
How would you use isPending to toggle the state of the submit button?

@jdalton jdalton closed this as completed Aug 31, 2016
@thenewguy
Copy link
Author

thenewguy commented Aug 31, 2016

It works with react like this on render:

<Button disabled={!this.propagateSearchState.isPending()}>
    &nbsp;
    <Glyphicon glyph="search"></Glyphicon>
    &nbsp;
</Button>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants