@gdjiami/jslib
Version:
Jiami FrontEnd helpers and Services
48 lines (47 loc) • 976 B
TypeScript
/**
* 函数相关工具函数
*/
/**
* 空函数,一般用于占位
*/
export declare const noop: (...args: any) => any;
/**
* 空函数,一般用于占位. 可以提供一个警告信息
*/
export declare const noopWithWarn: (message: string) => (...args: any) => any;
/**
* 销毁器队列,存储多个销毁器,在组件卸载时调用 clear 方法
*
* @example
*
* ```js
* useEffect(() => {
* const d = disposer()
* d.add(() => {
* ...
* return () => {
* // 销毁
* ...
* }
* })
* return d.clear
* })
*
* ```
*/
export declare function disposer(): {
add: (i: Function) => number;
clear: () => void;
};
/**
* 返回disposer的 setTimeout
*
* @param callback 延时操作方法
* @param time 延时时长
*
* @example
* ```js
* timeout(() => { ... }, 1000)
* ```
*/
export declare function timeout(callback: () => void, time: number): () => void;