You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| Auction, reservation, or job deadline | Core |`@crup/react-timer-hook`|[Absolute countdown](https://crup.github.io/react-timer-hook/recipes/basic/absolute-countdown/)|
61
+
| Focus timer or checkout hold that pauses | Core + duration |`@crup/react-timer-hook` + `/duration`|[Pausable countdown](https://crup.github.io/react-timer-hook/recipes/basic/pausable-countdown/)|
62
+
| Backend status polling | Schedules |`@crup/react-timer-hook/schedules`|[Polling schedule](https://crup.github.io/react-timer-hook/recipes/intermediate/polling-schedule/)|
63
+
| Polling that can close early | Schedules |`@crup/react-timer-hook/schedules`|[Poll and cancel](https://crup.github.io/react-timer-hook/recipes/intermediate/poll-and-cancel/)|
64
+
| Auction list with independent row controls | Timer group |`@crup/react-timer-hook/group`|[Timer group](https://crup.github.io/react-timer-hook/recipes/advanced/timer-group/)|
65
+
| Upload/job dashboard with per-row polling | Timer group + schedules |`@crup/react-timer-hook/group`|[Per-item polling](https://crup.github.io/react-timer-hook/recipes/advanced/per-item-polling/)|
66
+
| Toast expiry or runtime item timers | Timer group |`@crup/react-timer-hook/group`|[Dynamic items](https://crup.github.io/react-timer-hook/recipes/advanced/dynamic-items/)|
67
+
68
+
See the full use-case guide: https://crup.github.io/react-timer-hook/use-cases/
|`updateIntervalMs`|`number`| No | Render/update cadence in milliseconds. Defaults to `1000`. This does not define elapsed time; elapsed time is calculated from timestamps. Use a smaller value like `100` or `20` when the UI needs finer updates. |
153
169
|`endWhen`|`(snapshot) => boolean`| No | Ends the lifecycle when it returns `true`. Use this for countdowns, timeouts, and custom stop conditions. |
154
170
|`onEnd`|`(snapshot, controls) => void \| Promise<void>`| No | Called once per generation when `endWhen` ends the lifecycle. `restart()` creates a new generation. |
171
+
|`onError`|`(error, snapshot, controls) => void`| No | Handles sync throws and async rejections from `onEnd`. |
155
172
156
173
### `useScheduledTimer()` settings
157
174
@@ -163,6 +180,7 @@ Import from `@crup/react-timer-hook/schedules` when you need polling or schedule
163
180
|`updateIntervalMs`|`number`| No | Render/update cadence in milliseconds. Defaults to `1000`. Scheduled callbacks can run on their own cadence. |
164
181
|`endWhen`|`(snapshot) => boolean`| No | Ends the lifecycle when it returns `true`. |
165
182
|`onEnd`|`(snapshot, controls) => void \| Promise<void>`| No | Called once per generation when `endWhen` ends the lifecycle. |
183
+
|`onError`|`(error, snapshot, controls) => void`| No | Handles sync throws and async rejections from `onEnd`. |
166
184
|`schedules`|`TimerSchedule[]`| No | Scheduled side effects that run while the timer is active. Async overlap defaults to `skip`. |
167
185
|`diagnostics`|`TimerDiagnostics`| No | Optional lifecycle and schedule events. No logs are emitted unless you pass a logger. |
168
186
@@ -194,6 +212,7 @@ Import from `@crup/react-timer-hook/group` when many keyed items need independen
194
212
|`autoStart`|`boolean`| No | Starts the item automatically when it is added or synced. Defaults to `false`. |
195
213
|`endWhen`|`(snapshot) => boolean`| No | Ends that item when it returns `true`. |
196
214
|`onEnd`|`(snapshot, controls) => void \| Promise<void>`| No | Called once per item generation when that item ends naturally. |
215
+
|`onError`|`(error, snapshot, controls) => void`| No | Handles sync throws and async rejections from that item's `onEnd`. |
197
216
|`schedules`|`TimerSchedule[]`| No | Per-item schedules with the same contract as `useScheduledTimer()`. |
198
217
199
218
### Values and controls
@@ -227,9 +246,9 @@ The default import stays small. Add the other pieces only when that screen needs
227
246
228
247
| Piece | Import | Best for | Raw | Gzip | Brotli |
The third callback argument contains `scheduledAt`, `firedAt`, `nextRunAt`, `overdueCount`, and `effectiveEveryMs`.
41
+
42
+
When the schedule cadence changes, the active scheduler recalculates the next timeout immediately. Changing only the callback keeps the current cadence and uses the latest callback on the next run.
`onError` receives sync throws and async rejections from that item's `onEnd`.
36
+
37
+
When `items` is controlled by props, pass a new array/object when item definitions change. The store preserves state for existing IDs and syncs new callbacks, deadlines, and schedules without resetting the item generation.
`onEnd` fires once per generation. `restart()` creates a new generation.
28
29
30
+
`onError` receives sync throws and async rejections from `onEnd`.
31
+
29
32
The root `useTimer()` export is lifecycle-only to keep the default bundle small. Use `@crup/react-timer-hook/schedules` when you need polling schedules and schedule timing context.
0 commit comments