Skip to content

Commit

Permalink
Use lodash DebouncedFunc for throttled/debounced functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Aug 30, 2021
1 parent 75e6b4d commit 04b2b09
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ _Parameters_

_Returns_

- `TFunc & import('lodash').Cancelable`: Debounced function.
- `import('lodash').DebouncedFunc<TFunc>`: Debounced function.

### useFocusOnMount

Expand Down Expand Up @@ -452,7 +452,7 @@ _Parameters_

_Returns_

- `TFunc & import('lodash').Cancelable`: Throttled function.
- `import('lodash').DebouncedFunc<TFunc>`: Throttled function.

### useViewportMatch

Expand Down
2 changes: 1 addition & 1 deletion packages/compose/src/hooks/use-debounce/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { useEffect } from '@wordpress/element';
* @param {TFunc} fn The function to debounce.
* @param {number} [wait] The number of milliseconds to delay.
* @param {import('lodash').DebounceSettings} [options] The options object.
* @return {TFunc & import('lodash').Cancelable} Debounced function.
* @return {import('lodash').DebouncedFunc<TFunc>} Debounced function.
*/
export default function useDebounce( fn, wait, options ) {
/* eslint-enable jsdoc/valid-types */
Expand Down
2 changes: 1 addition & 1 deletion packages/compose/src/hooks/use-throttle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { useEffect } from '@wordpress/element';
* @param {TFunc} fn The function to throttle.
* @param {number} [wait] The number of milliseconds to throttle invocations to.
* @param {import('lodash').ThrottleSettings} [options] The options object. See linked documentation for details.
* @return {TFunc & import('lodash').Cancelable} Throttled function.
* @return {import('lodash').DebouncedFunc<TFunc>} Throttled function.
*/
export default function useThrottle( fn, wait, options ) {
const throttled = useMemoOne( () => throttle( fn, wait, options ), [
Expand Down

0 comments on commit 04b2b09

Please sign in to comment.