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