@bigbinary/neeto-commons-frontend 2.0.60 → 2.0.62

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/react-utils.d.ts CHANGED
@@ -134,6 +134,48 @@ export function copyToClipboard(text: string, configs?: {
134
134
  * @endexample
135
135
  */
136
136
  export function buildUrl(route: string, params: object): string;
137
+ type TimerType = {
138
+ lastUpdated: number;
139
+ interval: number;
140
+ };
141
+ /**
142
+ *
143
+ * The useTimer hook re-renders in the specified time interval. This can
144
+ *
145
+ * auto-update the rendered elapsed time in components without requiring the
146
+ *
147
+ * application to be manually refreshed.
148
+ *
149
+ * This hook accepts a single argument timerIntervalInSeconds, which is the
150
+ *
151
+ * number of seconds after which the component will re-render. The default value is
152
+ *
153
+ * 60 seconds.
154
+ *
155
+ * All invocations of useTimer hooks are attached to a single setInterval call
156
+ *
157
+ * which ticks every 1 second. So using that hook in multiple components won't
158
+ *
159
+ * cause any performance drop.
160
+ *
161
+ * Note that the maximum precision for useTimer hook is one second. In other
162
+ *
163
+ * words, there is a possibility that your component will take at most one more
164
+ *
165
+ * second than the scheduled time interval to re-render.
166
+ *
167
+ * @example
168
+ *
169
+ * import { useTimer } from "neetocommons/react-utils";
170
+ *
171
+ * const Component = () => {
172
+ * useTimer(timerIntervalInSeconds);
173
+ *
174
+ * // Rest of the component
175
+ * };
176
+ * @endexample
177
+ */
178
+ export function useTimer(interval: number): TimerType;
137
179
  type DateTimeType = string | number | dayjs.Dayjs | Date | null | undefined;
138
180
  export const timeFormat: {
139
181
  fromNow: (time: DateTimeType) => string;