@aiszlab/relax 1.2.28-beta.7 → 1.2.29
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/dist/hooks/use-debounce-callback.mjs +1 -1
- package/dist/hooks/use-event.d.ts +1 -1
- package/dist/hooks/use-event.mjs +3 -3
- package/dist/hooks/use-force-update.d.ts +3 -4
- package/dist/hooks/use-force-update.mjs +1 -4
- package/dist/hooks/use-throttle-callback.mjs +1 -1
- package/dist/hooks/use-timeout.d.ts +1 -5
- package/dist/hooks/use-timeout.mjs +3 -3
- package/dist/hooks/use-update-effect.d.ts +2 -2
- package/dist/hooks/use-update-effect.mjs +2 -2
- package/dist/utils/debounce.d.ts +4 -3
- package/dist/utils/debounce.mjs +1 -1
- package/dist/utils/throttle.d.ts +2 -2
- package/dist/utils/throttle.mjs +3 -3
- package/package.json +1 -1
|
@@ -30,7 +30,7 @@ const useDebounceCallback = (callback, wait = 1000) => {
|
|
|
30
30
|
};
|
|
31
31
|
}, [wait]);
|
|
32
32
|
const debounced = useMemo(() => ({
|
|
33
|
-
next: (
|
|
33
|
+
next: (value) => { var _a; return (_a = trigger.current) === null || _a === void 0 ? void 0 : _a.next(value); },
|
|
34
34
|
complete: () => { var _a; return (_a = trigger.current) === null || _a === void 0 ? void 0 : _a.complete(); },
|
|
35
35
|
cancel: () => { var _a; return (_a = trigger.current) === null || _a === void 0 ? void 0 : _a.cancel(); }
|
|
36
36
|
}), []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useEvent: <T extends Function>(
|
|
1
|
+
export declare const useEvent: <T extends Function>(callback: T) => T;
|
package/dist/hooks/use-event.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useRef, useCallback } from 'react';
|
|
2
2
|
|
|
3
|
-
const useEvent = (
|
|
4
|
-
const ref = useRef(
|
|
5
|
-
ref.current =
|
|
3
|
+
const useEvent = (callback) => {
|
|
4
|
+
const ref = useRef(callback);
|
|
5
|
+
ref.current = callback;
|
|
6
6
|
return useCallback(((...args) => ref.current(...args)), []);
|
|
7
7
|
};
|
|
8
8
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
type UsedForceUpdate = [number, () => void];
|
|
1
2
|
/**
|
|
2
3
|
* @description
|
|
3
4
|
* force update
|
|
4
5
|
*/
|
|
5
|
-
export declare const useForceUpdate: () =>
|
|
6
|
-
|
|
7
|
-
forceUpdate: () => void;
|
|
8
|
-
};
|
|
6
|
+
export declare const useForceUpdate: () => UsedForceUpdate;
|
|
7
|
+
export {};
|
|
@@ -30,7 +30,7 @@ const useThrottleCallback = (callback, duration = 1000) => {
|
|
|
30
30
|
};
|
|
31
31
|
}, [duration]);
|
|
32
32
|
const throttled = useMemo(() => ({
|
|
33
|
-
next: (
|
|
33
|
+
next: (value) => { var _a; return (_a = trigger.current) === null || _a === void 0 ? void 0 : _a.next(value); },
|
|
34
34
|
complete: () => { var _a; return (_a = trigger.current) === null || _a === void 0 ? void 0 : _a.complete(); },
|
|
35
35
|
cancel: () => { var _a; return (_a = trigger.current) === null || _a === void 0 ? void 0 : _a.cancel(); }
|
|
36
36
|
}), []);
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
interface Options {
|
|
2
|
-
duration: number;
|
|
3
|
-
}
|
|
4
1
|
/**
|
|
5
2
|
* @author murukal
|
|
6
3
|
*
|
|
7
4
|
* @description
|
|
8
5
|
* timeout effect
|
|
9
6
|
*/
|
|
10
|
-
export declare const useTimeout: (handler: Function,
|
|
11
|
-
export {};
|
|
7
|
+
export declare const useTimeout: (handler: Function, wait: number) => void;
|
|
@@ -6,15 +6,15 @@ import { useEffect } from 'react';
|
|
|
6
6
|
* @description
|
|
7
7
|
* timeout effect
|
|
8
8
|
*/
|
|
9
|
-
const useTimeout = (handler,
|
|
9
|
+
const useTimeout = (handler, wait) => {
|
|
10
10
|
useEffect(() => {
|
|
11
|
-
const timer = setTimeout(handler,
|
|
11
|
+
const timer = setTimeout(handler, wait);
|
|
12
12
|
return () => {
|
|
13
13
|
if (!timer)
|
|
14
14
|
return;
|
|
15
15
|
clearTimeout(timer);
|
|
16
16
|
};
|
|
17
|
-
}, [
|
|
17
|
+
}, [wait]);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export { useTimeout };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DependencyList } from 'react';
|
|
1
|
+
import { type DependencyList } from 'react';
|
|
2
2
|
import type { ThenableEffectCallback } from '../types';
|
|
3
|
-
export declare const useUpdateEffect: (
|
|
3
|
+
export declare const useUpdateEffect: (callback: ThenableEffectCallback, deps?: DependencyList) => void;
|
|
@@ -2,12 +2,12 @@ import { useRef, useEffect } from 'react';
|
|
|
2
2
|
import { useMounted } from './use-mounted.mjs';
|
|
3
3
|
import { effect } from '../utils/effect.mjs';
|
|
4
4
|
|
|
5
|
-
const useUpdateEffect = (
|
|
5
|
+
const useUpdateEffect = (callback, deps) => {
|
|
6
6
|
const isMounted = useRef(false);
|
|
7
7
|
useEffect(() => {
|
|
8
8
|
if (!isMounted.current)
|
|
9
9
|
return;
|
|
10
|
-
return effect(
|
|
10
|
+
return effect(callback);
|
|
11
11
|
}, deps);
|
|
12
12
|
useMounted(() => {
|
|
13
13
|
isMounted.current = true;
|
package/dist/utils/debounce.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Subscriber } from 'rxjs';
|
|
2
|
-
|
|
1
|
+
import { type Subscriber } from 'rxjs';
|
|
2
|
+
import type { Arguments, First } from '../types';
|
|
3
|
+
export interface Debounced<T extends Function> {
|
|
3
4
|
/**
|
|
4
5
|
* @description
|
|
5
6
|
* value trigger
|
|
6
7
|
*/
|
|
7
|
-
next: T;
|
|
8
|
+
next: (value: First<Arguments<T>>) => void;
|
|
8
9
|
/**
|
|
9
10
|
* @description
|
|
10
11
|
* complete current debounce function
|
package/dist/utils/debounce.mjs
CHANGED
package/dist/utils/throttle.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type Debounced } from './debounce';
|
|
2
|
-
export type Throttled<T> = Debounced<T>;
|
|
3
|
-
export declare const throttle: <T extends Function>(callback: T,
|
|
2
|
+
export type Throttled<T extends Function> = Debounced<T>;
|
|
3
|
+
export declare const throttle: <T extends Function>(callback: T, duration: number) => Throttled<T>;
|
package/dist/utils/throttle.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Observable, throttleTime } from 'rxjs';
|
|
2
2
|
import { Trigger } from './debounce.mjs';
|
|
3
3
|
|
|
4
|
-
const throttle = (callback,
|
|
4
|
+
const throttle = (callback, duration) => {
|
|
5
5
|
const trigger = new Trigger();
|
|
6
6
|
const listened = new Observable((subscriber) => {
|
|
7
7
|
trigger.use = subscriber;
|
|
8
8
|
})
|
|
9
|
-
.pipe(throttleTime(
|
|
9
|
+
.pipe(throttleTime(duration))
|
|
10
10
|
.subscribe((value) => {
|
|
11
11
|
callback(value);
|
|
12
12
|
});
|
|
13
13
|
return {
|
|
14
|
-
next: (
|
|
14
|
+
next: (value) => trigger.next(value),
|
|
15
15
|
complete: () => trigger.complete(),
|
|
16
16
|
cancel: () => {
|
|
17
17
|
listened.unsubscribe();
|