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

Option to wait before sending queries for asyncOptions #459

Closed
oliversong opened this issue Sep 18, 2015 · 6 comments
Closed

Option to wait before sending queries for asyncOptions #459

oliversong opened this issue Sep 18, 2015 · 6 comments

Comments

@oliversong
Copy link
Contributor

It would be nice if we could specify a time delay to wait after the last keystroke before calling asyncOptions, so it doesn't make unnecessary requests.

@PSkierniewski
Copy link

Bump, as far as I can see asyncOptions are fired on change, is it possible to fire it when user stops typing?

@oliversong
Copy link
Contributor Author

It's implemented in my branch #473 @PSkierniewski

@PSkierniewski
Copy link

@oliversong Thx I used it and it works.

@tommyalvarez
Copy link

tommyalvarez commented Aug 1, 2017

@oliversong i need this too. Can you check the PR for this feature to fix it so it can be merged?

@duytbp
Copy link

duytbp commented Aug 1, 2017

For those who might need, for now you can have debouncing by wrapping your loadOptions callback by lodash/debounce

const wait = 500; // milliseconds
const loadOptions = input => dataStore.getData(input)
const debouncedLoadOptions = _.debounce(loadOptions, wait)

return <Async loadOptions={debouncedLoadOptions} ... />

@craigmichaelmartin
Copy link

It looks like @JedWatson has expressed that this be left for users to implement in the function that's passed to loadOptions.

For those doing so, Lodash's debounce function is not suited for this. Instead, a promise-returning debounce method where subsequent calls return promises which will resolve to the result of the next func invocation in needed. See #3075 (comment)

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

No branches or pull requests

6 participants