MCPcopy
hub / github.com/xnimorz/use-debounce / shouldInvoke

Function shouldInvoke

src/useDebouncedCallback.ts:194–209  ·  view source on GitHub ↗
(time: number)

Source from the content-addressed store, hash-verified

192 };
193
194 const shouldInvoke = (time: number) => {
195 if (!mounted.current) return false;
196
197 const timeSinceLastCall = time - lastCallTime.current;
198 const timeSinceLastInvoke = time - lastInvokeTime.current;
199
200 // Either this is the first call, activity has stopped and we're at the
201 // trailing edge, the system time has gone backwards and we're treating
202 // it as the trailing edge, or we've hit the `maxWait` limit.
203 return (
204 !lastCallTime.current ||
205 timeSinceLastCall >= wait ||
206 timeSinceLastCall < 0 ||
207 (maxing && timeSinceLastInvoke >= maxWait)
208 );
209 };
210
211 const trailingEdge = (time: number) => {
212 timerId.current = null;

Callers 2

timerExpiredFunction · 0.85
funcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…