Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100847635
useDebouncedCallback.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Feb 3, 06:06
Size
657 B
Mime Type
text/x-java
Expires
Wed, Feb 5, 06:06 (1 d, 20 h)
Engine
blob
Format
Raw Data
Handle
24041217
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
useDebouncedCallback.js
View Options
import { useCallback } from 'react';
import useTimeout from './useTimeout';
/**
* Creates a debounced function that will invoke the input function after the
* specified delay.
*
* @param fn a function that will be debounced
* @param delay The milliseconds delay before invoking the function
*/
export default function useDebouncedCallback(fn, delay) {
var timeout = useTimeout();
return useCallback(function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
timeout.set(function () {
fn.apply(void 0, args);
}, delay);
}, [fn, delay]);
}
Event Timeline
Log In to Comment