Throttle

You can find an explanation of throttling hereopen in new window.

In simple terms, throttling ensures that a function is executed at a set interval of time, such as during an input event where the throttle function will execute the provided function at the set interval as the user inputs data. This is quite different from the debounce approach we discussed in the previous section.

VueRequest's throttle is implemented using throttleopen in new window provided by lodashopen in new window, and the leading and trailing options are set to true by default, which means that two requests may be triggered in the first throttling interval.

You can customize the behavior of throttle using throttleOptions.

As shown below, you only need to provide a throttleInterval to specify the interval for executing throttling. This way, when the user inputs information, we will send a request every 1000 milliseconds.

You can open the console to view the interval of console log messages.

Last Updated: 7/6/2023, 3:23:08 AM
Contributors: John