The function to debounce.
The delay before the function is called.
Optionalimmediate?: booleanWhether the function should be called immediately. Default is false.
If true, the function will be called immediately and then debounced.
If the function is called multiple times during the timeout, it will only be called once.
A debounce function ensures that a function is not called too frequently. It only allows the function to be executed after a specified delay has passed since the last call.