main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
679 bytes
|
Line | |
---|
1 | import { useEffect, useRef } from 'react';
|
---|
2 | import { clearHarmonicInterval, setHarmonicInterval } from 'set-harmonic-interval';
|
---|
3 | var useHarmonicIntervalFn = function (fn, delay) {
|
---|
4 | if (delay === void 0) { delay = 0; }
|
---|
5 | var latestCallback = useRef(function () { });
|
---|
6 | useEffect(function () {
|
---|
7 | latestCallback.current = fn;
|
---|
8 | });
|
---|
9 | useEffect(function () {
|
---|
10 | if (delay !== null) {
|
---|
11 | var interval_1 = setHarmonicInterval(function () { return latestCallback.current(); }, delay);
|
---|
12 | return function () { return clearHarmonicInterval(interval_1); };
|
---|
13 | }
|
---|
14 | return undefined;
|
---|
15 | }, [delay]);
|
---|
16 | };
|
---|
17 | export default useHarmonicIntervalFn;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.