Skip to content

Commit fb22c67

Browse files
committed
ref: use notifyManager.schedule in createPersister
because it needs to work with whatever scheduleFn we have set there
1 parent 841ac54 commit fb22c67

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/query-core/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export { QueryClient } from './queryClient'
2020
export { QueryObserver } from './queryObserver'
2121
export { CancelledError, isCancelledError } from './retryer'
2222
export {
23-
systemSetTimeoutZero,
2423
timeoutManager,
2524
type ManagedTimerId,
2625
type TimeoutCallback,

packages/query-persist-client-core/src/createPersister.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
22
hashKey,
33
matchQuery,
4+
notifyManager,
45
partialMatchKey,
5-
systemSetTimeoutZero,
66
} from '@tanstack/query-core'
77
import type {
88
Query,
@@ -130,7 +130,9 @@ export function experimental_createQueryPersister<TStorageValue = string>({
130130
} else {
131131
if (afterRestoreMacroTask) {
132132
// Just after restoring we want to get fresh data from the server if it's stale
133-
systemSetTimeoutZero(() => afterRestoreMacroTask(persistedQuery))
133+
notifyManager.schedule(() =>
134+
afterRestoreMacroTask(persistedQuery),
135+
)
134136
}
135137
// We must resolve the promise here, as otherwise we will have `loading` state in the app until `queryFn` resolves
136138
return persistedQuery.state.data as T
@@ -218,7 +220,7 @@ export function experimental_createQueryPersister<TStorageValue = string>({
218220

219221
if (matchesFilter && storage != null) {
220222
// Persist if we have storage defined, we use timeout to get proper state to be persisted
221-
systemSetTimeoutZero(() => {
223+
notifyManager.schedule(() => {
222224
persistQuery(query)
223225
})
224226
}

0 commit comments

Comments
 (0)