wire-elements / spotlight

Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.
MIT License
912 stars 71 forks source link

Config option for debounce (maybe even debounce on based on expected search time) #84

Closed manuelsteiner closed 2 years ago

manuelsteiner commented 2 years ago

Hi,

after finding issue #40, I am wondering if it is a good idea to offer debouncing via an option in the configuration file or maybe even on a more fine grained basis based on dependency searches. It might make sense to distinguish between different actions in terms of expected finish time of searches.

Scenario Consider the normal spotlight command search that filters the available commands. This is usually pretty fast and can easily be done after each keystroke. However, filtering through dependencies that might take a while to fetch from the backend takes a while and could the resulting behaviour of loading the results might not always be as smooth and could lead to unexpected behaviour while typing. This can be improved with x-model.debounce.

Possible improvement However, the x-model.debounce might not be wanted on all searches. Maybe we could introdue an attribute on dependecies to indicate if debouncing should be done or not and then conditionally use x-model or x-model.debounce. I haven't had a close look yetif that is easily doable.

Alternatively just providing a global configuration flag to enable or disable debouncing would also be an option.

If that sounds like something you are interested in, I can work on a PR.

PhiloNL commented 2 years ago

Sounds like a good addition. Feel free to submit a PR 😄