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

Debounce does not work? #146

Closed
tripper54 opened this issue Feb 27, 2017 · 12 comments
Closed

Debounce does not work? #146

tripper54 opened this issue Feb 27, 2017 · 12 comments
Labels

Comments

@tripper54
Copy link

My onSearch function runs on every keypress regardless of what I set the debounce prop to:

http://jsbin.com/zuhusiwadu/1/edit?html,js,console,output

@sagalbot sagalbot added the bug label Feb 28, 2017
@sagalbot
Copy link
Owner

Looks like debounce fell through the cracks on the v1 to v2 upgrade. I'll get that fixed in a new release.

In the meantime, you can bring in debounce from underscore or lodash and debounce your method instead:

http://jsbin.com/cimoho/edit?html,js,output

@tripper54
Copy link
Author

Thanks, lodash does indeed do the job!

@sagalbot
Copy link
Owner

It sure does. I'll probably end up pulling in lodash/debounce anyways as the debounce filter is gone in Vue2.

@tripper54
Copy link
Author

Have you thought about dropping the feature, for the same reason Evan dropped it from Vue?

That way we can pull it in or not on our side depending if we need it.

@sagalbot
Copy link
Owner

I've had that thought, but now you've got me really thinking about it.

In the case of this component I don't think the details around losing access to the inputs state apply, but the argument around needing throttle vs. debounce does make sense here. The other issue is file size - I really want to keep things as lean as possible. So leaving out debounce is a plus there. Also less work for me 👍 .

The only advantage of baking it right into the component is that it likely fit's the 80/20 rule where it does make things easier for the majority of the user base (but maybe you could have said the same about the debounce filter). On the flipside - if a user is already pulling in lodash/underscore, then I'm adding duplicate bulk.

I'm leaning towards dropping it.

@tripper54
Copy link
Author

If my vote counts for anything, I'd say drop it.

As you mention, it's less work for you, and it means we can choose lodash/underscore, debounce/throttle.

In my case I was already using lodash/debounce, so it's better for me if it's not duplicated. I guess that's a likely scenario now that Vue doesn't include a debouncer.

If there's overwhelming public outcry, you can always reconsider!

@sagalbot
Copy link
Owner

Your vote counts for a lot. One thing I've learned about writing open source stuff is that feedback is critical to success - ignore the users and no one's going to use your stuff.

Done deal, debounce is getting canned! Thanks for taking the time to chat about it.

@sagalbot
Copy link
Owner

deprecate debounce

@ankurk91
Copy link

@sagalbot
Please also remove :debounce from example on gh-pages

@evan-coygo
Copy link

It would be really great to have an example of how to implement debounce ourselves in the docs using lodash/underscore. I tried making the :filter='filterFn' a debounced method (returning a Fuse.js search for fuzzy search) but had some strange behavior

@evan-coygo
Copy link

@sagalbot do you have any working examples of implementing debounce with newer versions of this lib?

@sagalbot
Copy link
Owner

@evan-coygo https://codepen.io/sagalbot/pen/PpeJGE?editors=1010

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

No branches or pull requests

4 participants