@pyreon/hooks 0.11.4 → 0.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +2 -2
- package/lib/index.js +4 -6
- package/package.json +6 -6
- package/src/useInterval.ts +2 -3
- package/src/useTimeout.ts +2 -3
package/lib/index.d.ts
CHANGED
|
@@ -239,7 +239,7 @@ type UseInterval = (callback: () => void, delay: number | null) => void;
|
|
|
239
239
|
/**
|
|
240
240
|
* Declarative `setInterval` with auto-cleanup.
|
|
241
241
|
* Pass `null` as `delay` to pause the interval.
|
|
242
|
-
*
|
|
242
|
+
* In Pyreon, components run once — callback is captured at setup time.
|
|
243
243
|
*/
|
|
244
244
|
declare const useInterval: UseInterval;
|
|
245
245
|
//#endregion
|
|
@@ -438,7 +438,7 @@ type UseTimeout = (callback: () => void, delay: number | null) => {
|
|
|
438
438
|
/**
|
|
439
439
|
* Declarative `setTimeout` with auto-cleanup.
|
|
440
440
|
* Pass `null` as `delay` to disable. Returns `reset` and `clear` controls.
|
|
441
|
-
*
|
|
441
|
+
* In Pyreon, components run once — callback is captured at setup time.
|
|
442
442
|
*/
|
|
443
443
|
declare const useTimeout: UseTimeout;
|
|
444
444
|
//#endregion
|
package/lib/index.js
CHANGED
|
@@ -524,14 +524,13 @@ function useIntersection(getEl, options) {
|
|
|
524
524
|
/**
|
|
525
525
|
* Declarative `setInterval` with auto-cleanup.
|
|
526
526
|
* Pass `null` as `delay` to pause the interval.
|
|
527
|
-
*
|
|
527
|
+
* In Pyreon, components run once — callback is captured at setup time.
|
|
528
528
|
*/
|
|
529
529
|
const useInterval = (callback, delay) => {
|
|
530
|
-
const currentCallback = callback;
|
|
531
530
|
let intervalId = null;
|
|
532
531
|
const start = () => {
|
|
533
532
|
if (delay === null) return;
|
|
534
|
-
intervalId = setInterval(() =>
|
|
533
|
+
intervalId = setInterval(() => callback(), delay);
|
|
535
534
|
};
|
|
536
535
|
const stop = () => {
|
|
537
536
|
if (intervalId != null) {
|
|
@@ -876,10 +875,9 @@ function useTimeAgo(date, options) {
|
|
|
876
875
|
/**
|
|
877
876
|
* Declarative `setTimeout` with auto-cleanup.
|
|
878
877
|
* Pass `null` as `delay` to disable. Returns `reset` and `clear` controls.
|
|
879
|
-
*
|
|
878
|
+
* In Pyreon, components run once — callback is captured at setup time.
|
|
880
879
|
*/
|
|
881
880
|
const useTimeout = (callback, delay) => {
|
|
882
|
-
const currentCallback = callback;
|
|
883
881
|
let timer = null;
|
|
884
882
|
const clear = () => {
|
|
885
883
|
if (timer != null) {
|
|
@@ -891,7 +889,7 @@ const useTimeout = (callback, delay) => {
|
|
|
891
889
|
clear();
|
|
892
890
|
if (delay !== null) timer = setTimeout(() => {
|
|
893
891
|
timer = null;
|
|
894
|
-
|
|
892
|
+
callback();
|
|
895
893
|
}, delay);
|
|
896
894
|
};
|
|
897
895
|
reset();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/hooks",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/pyreon/pyreon",
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"typecheck": "tsc --noEmit"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@pyreon/core": "^0.11.
|
|
48
|
-
"@pyreon/reactivity": "^0.11.
|
|
49
|
-
"@pyreon/styler": "^0.11.
|
|
50
|
-
"@pyreon/ui-core": "^0.11.
|
|
47
|
+
"@pyreon/core": "^0.11.5",
|
|
48
|
+
"@pyreon/reactivity": "^0.11.5",
|
|
49
|
+
"@pyreon/styler": "^0.11.5",
|
|
50
|
+
"@pyreon/ui-core": "^0.11.5"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@vitus-labs/tools-rolldown": "^1.15.3",
|
|
54
|
-
"@pyreon/typescript": "^0.11.
|
|
54
|
+
"@pyreon/typescript": "^0.11.5"
|
|
55
55
|
}
|
|
56
56
|
}
|
package/src/useInterval.ts
CHANGED
|
@@ -5,15 +5,14 @@ export type UseInterval = (callback: () => void, delay: number | null) => void
|
|
|
5
5
|
/**
|
|
6
6
|
* Declarative `setInterval` with auto-cleanup.
|
|
7
7
|
* Pass `null` as `delay` to pause the interval.
|
|
8
|
-
*
|
|
8
|
+
* In Pyreon, components run once — callback is captured at setup time.
|
|
9
9
|
*/
|
|
10
10
|
export const useInterval: UseInterval = (callback, delay) => {
|
|
11
|
-
const currentCallback = callback
|
|
12
11
|
let intervalId: ReturnType<typeof setInterval> | null = null
|
|
13
12
|
|
|
14
13
|
const start = () => {
|
|
15
14
|
if (delay === null) return
|
|
16
|
-
intervalId = setInterval(() =>
|
|
15
|
+
intervalId = setInterval(() => callback(), delay)
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
const stop = () => {
|
package/src/useTimeout.ts
CHANGED
|
@@ -8,10 +8,9 @@ export type UseTimeout = (
|
|
|
8
8
|
/**
|
|
9
9
|
* Declarative `setTimeout` with auto-cleanup.
|
|
10
10
|
* Pass `null` as `delay` to disable. Returns `reset` and `clear` controls.
|
|
11
|
-
*
|
|
11
|
+
* In Pyreon, components run once — callback is captured at setup time.
|
|
12
12
|
*/
|
|
13
13
|
export const useTimeout: UseTimeout = (callback, delay) => {
|
|
14
|
-
const currentCallback = callback
|
|
15
14
|
let timer: ReturnType<typeof setTimeout> | null = null
|
|
16
15
|
|
|
17
16
|
const clear = () => {
|
|
@@ -26,7 +25,7 @@ export const useTimeout: UseTimeout = (callback, delay) => {
|
|
|
26
25
|
if (delay !== null) {
|
|
27
26
|
timer = setTimeout(() => {
|
|
28
27
|
timer = null
|
|
29
|
-
|
|
28
|
+
callback()
|
|
30
29
|
}, delay)
|
|
31
30
|
}
|
|
32
31
|
}
|