emilianotisato / nova-google-autocomplete-field

Address Autocomplete with Google Place API (full metadata available)
20 stars 17 forks source link

Debounce after 5 seconds #2

Closed waygou closed 3 years ago

waygou commented 6 years ago

Hi,

Thanks for building this field, it have a lot of potential to be used widely!

Still, I think there is an enhancement that will allow the google places api quota (for free usage) not to be exceeded so fast, in case you can use a debounce option.

Meaning, you should only send the request when the user "stops writing in the field after X seconds".

User starts writing the address. Then he stops writing. Field waits 5 seconds. Then makes the HTTP call.

This would reduce drastically the usage of the HTTP requests to the Google places API.

Thanks, Bruno

emilianotisato commented 6 years ago

Hello @waygou ,

You are right. You can send me a PR, or wait a few days til I make the change...

Thanks

Emiliano

waygou commented 6 years ago

Thanks! And no worries, I can wait since I'm working on other parts of my project atm.

Cheers, Bruno

emilianotisato commented 6 years ago

Ok, @waygou ,

Since this package is based on olefirenko/vue-google-autocomplete packages.

I am participating on this discussion. Because at this moment I don't see how can I implement this "delaying" feature...

waygou commented 6 years ago

I'll check it out too, and come back as soon as I have feedback. We might need to defer the placechanged event to an intermediate event that will watch the input value being changed.

Will try to code it this weekend.