Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121607188
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
Sat, Jul 12, 10:01
Size
657 B
Mime Type
text/x-java
Expires
Mon, Jul 14, 10:01 (2 d)
Engine
blob
Format
Raw Data
Handle
27357199
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