[IMP] web: expose immediate in useDebounced hook
Expose all debounced param in the hook. closes odoo/odoo#106762 Signed-off-by: Géry Debongnie <ged@odoo.com>
This commit is contained in:
@@ -119,11 +119,13 @@ export function debounce(func, delay, immediate = false) {
|
||||
* @template {Function} T
|
||||
* @param {T} callback
|
||||
* @param {number | "animationFrame"} delay
|
||||
* @param {boolean} [immediate=false] whether the function should be called on
|
||||
* the leading edge instead of the trailing edge.
|
||||
* @returns {T & { cancel: () => void }}
|
||||
*/
|
||||
export function useDebounced(callback, delay) {
|
||||
export function useDebounced(callback, delay, immediate = false) {
|
||||
const component = useComponent();
|
||||
const debounced = debounce(callback.bind(component), delay);
|
||||
const debounced = debounce(callback.bind(component), delay, immediate);
|
||||
onWillUnmount(() => debounced.cancel());
|
||||
return debounced;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user