Skip to content

Commit 47962fd

Browse files
committed
query-async-storage-persister: use query-core managedSetTimeout
1 parent 0fac7b2 commit 47962fd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/query-async-storage-persister/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"!src/__tests__"
6060
],
6161
"dependencies": {
62+
"@tanstack/query-core": "workspace:*",
6263
"@tanstack/query-persist-client-core": "workspace:*"
6364
},
6465
"devDependencies": {

packages/query-async-storage-persister/src/asyncThrottle.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { managedSetTimeout } from '@tanstack/query-core'
12
import { noop } from './utils'
23

34
interface AsyncThrottleOptions {
@@ -21,11 +22,11 @@ export function asyncThrottle<TArgs extends ReadonlyArray<unknown>>(
2122
if (isScheduled) return
2223
isScheduled = true
2324
while (isExecuting) {
24-
await new Promise((done) => setTimeout(done, interval))
25+
await new Promise((done) => managedSetTimeout(done, interval))
2526
}
2627
while (Date.now() < nextExecutionTime) {
2728
await new Promise((done) =>
28-
setTimeout(done, nextExecutionTime - Date.now()),
29+
managedSetTimeout(done, nextExecutionTime - Date.now()),
2930
)
3031
}
3132
isScheduled = false

0 commit comments

Comments
 (0)