@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.
@@ -30,7 +30,7 @@ const useDebounceCallback = (callback, wait = 1000) => {
30
30
  };
31
31
  }, [wait]);
32
32
  const debounced = useMemo(() => ({
33
- next: ((...args) => { var _a; return (_a = trigger.current) === null || _a === void 0 ? void 0 : _a.next(...args); }),
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>(callable: T) => T;
1
+ export declare const useEvent: <T extends Function>(callback: T) => T;
@@ -1,8 +1,8 @@
1
1
  import { useRef, useCallback } from 'react';
2
2
 
3
- const useEvent = (callable) => {
4
- const ref = useRef(callable);
5
- ref.current = callable;
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
- times: number;
7
- forceUpdate: () => void;
8
- };
6
+ export declare const useForceUpdate: () => UsedForceUpdate;
7
+ export {};
@@ -9,10 +9,7 @@ const useForceUpdate = () => {
9
9
  const forceUpdate = useCallback(() => {
10
10
  setTimes((prev) => prev + 1);
11
11
  }, []);
12
- return {
13
- times,
14
- forceUpdate
15
- };
12
+ return [times, forceUpdate];
16
13
  };
17
14
 
18
15
  export { useForceUpdate };
@@ -30,7 +30,7 @@ const useThrottleCallback = (callback, duration = 1000) => {
30
30
  };
31
31
  }, [duration]);
32
32
  const throttled = useMemo(() => ({
33
- next: ((...args) => { var _a; return (_a = trigger.current) === null || _a === void 0 ? void 0 : _a.next(...args); }),
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, { duration }: Options) => void;
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, { duration }) => {
9
+ const useTimeout = (handler, wait) => {
10
10
  useEffect(() => {
11
- const timer = setTimeout(handler, duration);
11
+ const timer = setTimeout(handler, wait);
12
12
  return () => {
13
13
  if (!timer)
14
14
  return;
15
15
  clearTimeout(timer);
16
16
  };
17
- }, [duration]);
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: (callable: ThenableEffectCallback, deps?: DependencyList) => void;
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 = (callable, deps) => {
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(callable);
10
+ return effect(callback);
11
11
  }, deps);
12
12
  useMounted(() => {
13
13
  isMounted.current = true;
@@ -1,10 +1,11 @@
1
- import { Subscriber } from 'rxjs';
2
- export interface Debounced<T> {
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
@@ -40,7 +40,7 @@ const debounce = (callback, wait) => {
40
40
  callback(value);
41
41
  });
42
42
  return {
43
- next: ((value) => trigger.next(value)),
43
+ next: (value) => trigger.next(value),
44
44
  complete: () => trigger.complete(),
45
45
  cancel: () => {
46
46
  listened.unsubscribe();
@@ -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, wait: number) => Throttled<T>;
2
+ export type Throttled<T extends Function> = Debounced<T>;
3
+ export declare const throttle: <T extends Function>(callback: T, duration: number) => Throttled<T>;
@@ -1,17 +1,17 @@
1
1
  import { Observable, throttleTime } from 'rxjs';
2
2
  import { Trigger } from './debounce.mjs';
3
3
 
4
- const throttle = (callback, wait) => {
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(wait))
9
+ .pipe(throttleTime(duration))
10
10
  .subscribe((value) => {
11
11
  callback(value);
12
12
  });
13
13
  return {
14
- next: ((value) => trigger.next(value)),
14
+ next: (value) => trigger.next(value),
15
15
  complete: () => trigger.complete(),
16
16
  cancel: () => {
17
17
  listened.unsubscribe();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiszlab/relax",
3
- "version": "1.2.28-beta.7",
3
+ "version": "1.2.29",
4
4
  "description": "react utils collection",
5
5
  "type": "module",
6
6
  "exports": {