UNPKG

rvx

Version:

A signal based rendering library

43 lines (42 loc) 2.05 kB
/** * The same as {@link queueMicrotask}, but with lifecycle support. * * + If the current lifecycle is disposed, the callback is never called. * + The lifecycle within the callback is treated as the current lifecycle. * * @param callback The callback to run as a microtask. * @throws An error if teardown hooks are explicitly un-supported in this context. */ export declare function useMicrotask(callback: () => void): void; /** * The same as {@link setTimeout}, but with lifecycle support. * * + If the current lifecycle is disposed, the timeout is {@link clearTimeout cleared}. * + The lifecycle within the callback is treated as the current lifecycle. * * @param callback The callback to run. * @param timeout The timeout in milliseconds. See {@link setTimeout} for details. * @throws An error if teardown hooks are explicitly un-supported in this context. */ export declare function useTimeout(callback: () => void, timeout: number): void; /** * The same as {@link setInterval}, but with lifecycle support. * * + If the current lifecycle is disposed, the interval is {@link clearInterval cleared}. * + The lifecycle within the callback is disposed when the interval is cleared and before each call. * * @param callback The callback to run. * @param interval The interval in milliseconds. See {@link setInterval} for details. * @throws An error if teardown hooks are explicitly un-supported in this context. */ export declare function useInterval(callback: () => void, interval: number): void; /** * Repeatedly {@link requestAnimationFrame request animation frames}. * * + If the current lifecycle is disposed, the latest request is cancelled. * + The lifecycle within the callback is disposed before each call and when the current lifecycle is disposed. * * @param callback The callback to run with a {@link performance.now high resolution timestamp}. * @throws An error if teardown hooks are explicitly un-supported in this context. */ export declare function useAnimation(callback: (now: number) => void): void;