Vue-select: Debounce does not work?

Created on 27 Feb 2017  路  12Comments  路  Source: sagalbot/vue-select

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

bug

Most helpful comment

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

All 12 comments

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

Thanks, lodash does indeed do the job!

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

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.

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.

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!

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
Please also remove :debounce from example on gh-pages

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FrozenIce0617 picture FrozenIce0617  路  3Comments

rafalolszewski94 picture rafalolszewski94  路  3Comments

FrancescoMussi picture FrancescoMussi  路  3Comments

davidalvarezr picture davidalvarezr  路  3Comments

edalzell picture edalzell  路  3Comments