import { useEffect } from "react";
import dayjs from "dayjs";
//#region src/components/pisellTimeNavigator/hooks/useRealtime.ts
/**
* Realtime 模式：每秒将当前系统时间通过 onTick 回传
*/
function useRealtime(enabled, onTick) {
	useEffect(() => {
		if (!enabled) return;
		const id = setInterval(() => {
			onTick(dayjs());
		}, 1e3);
		return () => clearInterval(id);
	}, [enabled, onTick]);
}
//#endregion
export { useRealtime };
