File tree 2 files changed +11
-11
lines changed
2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
2
* @todo Things that still need to be done before this can be called done:
3
- *
4
- * 1. Fill out all incomplete methods
5
- * 2. Add tests
3
+ * 1. Add tests and address any bugs
6
4
*/
7
5
import {
8
6
type FC ,
@@ -233,7 +231,7 @@ function areDepsInvalidated(
233
231
return false ;
234
232
}
235
233
236
- type UseTimeSyncSelectOptions < T = Date > = Readonly <
234
+ type UseTimeSyncSelectOptions < T > = Readonly <
237
235
UseTimeSyncOptions & {
238
236
/**
239
237
* selectDependencies acts like the dependency array for a useMemo
@@ -271,9 +269,7 @@ type UseTimeSyncSelectOptions<T = Date> = Readonly<
271
269
* frequent update interval, both component instances will update on that
272
270
* interval.
273
271
*/
274
- export function useTimeSyncSelect < T = Date > (
275
- options : UseTimeSyncSelectOptions < T > ,
276
- ) : T {
272
+ export function useTimeSyncSelect < T > ( options : UseTimeSyncSelectOptions < T > ) : T {
277
273
const { select, selectDependencies, targetRefreshInterval } = options ;
278
274
const hookId = useId ( ) ;
279
275
const timeSync = useTimeSyncContext ( ) ;
Original file line number Diff line number Diff line change 1
1
/**
2
2
* @todo What's left to do here:
3
3
* 1. Fill out all incomplete methods
4
- * 2. Make sure the class respects the resyncOnNewSubscription option
5
- * 3. Add tests
4
+ * 2. Refactor as necessary
5
+ * 3. Add tests and address any bugs
6
6
*/
7
7
export const TARGET_REFRESH_ONE_SECOND = 1_000 ;
8
8
export const TARGET_REFRESH_ONE_MINUTE = 60 * 1_000 ;
@@ -213,9 +213,13 @@ export class TimeSync implements TimeSyncApi {
213
213
}
214
214
215
215
subscribe ( entry : SubscriptionEntry ) : void {
216
- if ( entry . targetRefreshInterval <= 0 ) {
216
+ const intervalIsValid =
217
+ entry . targetRefreshInterval > 0 &&
218
+ ( Number . isInteger ( entry . targetRefreshInterval ) ||
219
+ entry . targetRefreshInterval === Number . POSITIVE_INFINITY ) ;
220
+ if ( ! intervalIsValid ) {
217
221
throw new Error (
218
- `Refresh interval ${ entry . targetRefreshInterval } must be a positive integer (or Infinity)` ,
222
+ `Refresh interval ${ entry . targetRefreshInterval } must be a positive integer or Positive Infinity)` ,
219
223
) ;
220
224
}
221
225
You can’t perform that action at this time.
0 commit comments