@tanstack/query-core
Advanced tools
Comparing version 5.55.3 to 5.55.4
@@ -8,5 +8,16 @@ type NotifyCallback = () => void; | ||
readonly batch: <T>(callback: () => T) => T; | ||
/** | ||
* All calls to the wrapped function will be batched. | ||
*/ | ||
readonly batchCalls: <T_1 extends unknown[]>(callback: BatchCallsCallback<T_1>) => BatchCallsCallback<T_1>; | ||
readonly schedule: (callback: NotifyCallback) => void; | ||
/** | ||
* Use this method to set a custom notify function. | ||
* This can be used to for example wrap notifications with `React.act` while running tests. | ||
*/ | ||
readonly setNotifyFunction: (fn: NotifyFunction) => void; | ||
/** | ||
* Use this method to set a custom function to batch notifications together into a single tick. | ||
* By default React Query will use the batch function provided by ReactDOM or React Native. | ||
*/ | ||
readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void; | ||
@@ -17,5 +28,16 @@ readonly setScheduler: (fn: ScheduleFunction) => void; | ||
readonly batch: <T>(callback: () => T) => T; | ||
/** | ||
* All calls to the wrapped function will be batched. | ||
*/ | ||
readonly batchCalls: <T_1 extends unknown[]>(callback: BatchCallsCallback<T_1>) => BatchCallsCallback<T_1>; | ||
readonly schedule: (callback: NotifyCallback) => void; | ||
/** | ||
* Use this method to set a custom notify function. | ||
* This can be used to for example wrap notifications with `React.act` while running tests. | ||
*/ | ||
readonly setNotifyFunction: (fn: NotifyFunction) => void; | ||
/** | ||
* Use this method to set a custom function to batch notifications together into a single tick. | ||
* By default React Query will use the batch function provided by ReactDOM or React Native. | ||
*/ | ||
readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void; | ||
@@ -22,0 +44,0 @@ readonly setScheduler: (fn: ScheduleFunction) => void; |
@@ -14,18 +14,2 @@ import "./chunk-2HYBKCYP.js"; | ||
let scheduleFn = (cb) => setTimeout(cb, 0); | ||
const setScheduler = (fn) => { | ||
scheduleFn = fn; | ||
}; | ||
const batch = (callback) => { | ||
let result; | ||
transactions++; | ||
try { | ||
result = callback(); | ||
} finally { | ||
transactions--; | ||
if (!transactions) { | ||
flush(); | ||
} | ||
} | ||
return result; | ||
}; | ||
const schedule = (callback) => { | ||
@@ -40,9 +24,2 @@ if (transactions) { | ||
}; | ||
const batchCalls = (callback) => { | ||
return (...args) => { | ||
schedule(() => { | ||
callback(...args); | ||
}); | ||
}; | ||
}; | ||
const flush = () => { | ||
@@ -61,15 +38,44 @@ const originalQueue = queue; | ||
}; | ||
const setNotifyFunction = (fn) => { | ||
notifyFn = fn; | ||
}; | ||
const setBatchNotifyFunction = (fn) => { | ||
batchNotifyFn = fn; | ||
}; | ||
return { | ||
batch, | ||
batchCalls, | ||
batch: (callback) => { | ||
let result; | ||
transactions++; | ||
try { | ||
result = callback(); | ||
} finally { | ||
transactions--; | ||
if (!transactions) { | ||
flush(); | ||
} | ||
} | ||
return result; | ||
}, | ||
/** | ||
* All calls to the wrapped function will be batched. | ||
*/ | ||
batchCalls: (callback) => { | ||
return (...args) => { | ||
schedule(() => { | ||
callback(...args); | ||
}); | ||
}; | ||
}, | ||
schedule, | ||
setNotifyFunction, | ||
setBatchNotifyFunction, | ||
setScheduler | ||
/** | ||
* Use this method to set a custom notify function. | ||
* This can be used to for example wrap notifications with `React.act` while running tests. | ||
*/ | ||
setNotifyFunction: (fn) => { | ||
notifyFn = fn; | ||
}, | ||
/** | ||
* Use this method to set a custom function to batch notifications together into a single tick. | ||
* By default React Query will use the batch function provided by ReactDOM or React Native. | ||
*/ | ||
setBatchNotifyFunction: (fn) => { | ||
batchNotifyFn = fn; | ||
}, | ||
setScheduler: (fn) => { | ||
scheduleFn = fn; | ||
} | ||
}; | ||
@@ -76,0 +82,0 @@ } |
@@ -8,5 +8,16 @@ type NotifyCallback = () => void; | ||
readonly batch: <T>(callback: () => T) => T; | ||
/** | ||
* All calls to the wrapped function will be batched. | ||
*/ | ||
readonly batchCalls: <T_1 extends unknown[]>(callback: BatchCallsCallback<T_1>) => BatchCallsCallback<T_1>; | ||
readonly schedule: (callback: NotifyCallback) => void; | ||
/** | ||
* Use this method to set a custom notify function. | ||
* This can be used to for example wrap notifications with `React.act` while running tests. | ||
*/ | ||
readonly setNotifyFunction: (fn: NotifyFunction) => void; | ||
/** | ||
* Use this method to set a custom function to batch notifications together into a single tick. | ||
* By default React Query will use the batch function provided by ReactDOM or React Native. | ||
*/ | ||
readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void; | ||
@@ -17,5 +28,16 @@ readonly setScheduler: (fn: ScheduleFunction) => void; | ||
readonly batch: <T>(callback: () => T) => T; | ||
/** | ||
* All calls to the wrapped function will be batched. | ||
*/ | ||
readonly batchCalls: <T_1 extends unknown[]>(callback: BatchCallsCallback<T_1>) => BatchCallsCallback<T_1>; | ||
readonly schedule: (callback: NotifyCallback) => void; | ||
/** | ||
* Use this method to set a custom notify function. | ||
* This can be used to for example wrap notifications with `React.act` while running tests. | ||
*/ | ||
readonly setNotifyFunction: (fn: NotifyFunction) => void; | ||
/** | ||
* Use this method to set a custom function to batch notifications together into a single tick. | ||
* By default React Query will use the batch function provided by ReactDOM or React Native. | ||
*/ | ||
readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void; | ||
@@ -22,0 +44,0 @@ readonly setScheduler: (fn: ScheduleFunction) => void; |
@@ -12,18 +12,2 @@ // src/notifyManager.ts | ||
let scheduleFn = (cb) => setTimeout(cb, 0); | ||
const setScheduler = (fn) => { | ||
scheduleFn = fn; | ||
}; | ||
const batch = (callback) => { | ||
let result; | ||
transactions++; | ||
try { | ||
result = callback(); | ||
} finally { | ||
transactions--; | ||
if (!transactions) { | ||
flush(); | ||
} | ||
} | ||
return result; | ||
}; | ||
const schedule = (callback) => { | ||
@@ -38,9 +22,2 @@ if (transactions) { | ||
}; | ||
const batchCalls = (callback) => { | ||
return (...args) => { | ||
schedule(() => { | ||
callback(...args); | ||
}); | ||
}; | ||
}; | ||
const flush = () => { | ||
@@ -59,15 +36,44 @@ const originalQueue = queue; | ||
}; | ||
const setNotifyFunction = (fn) => { | ||
notifyFn = fn; | ||
}; | ||
const setBatchNotifyFunction = (fn) => { | ||
batchNotifyFn = fn; | ||
}; | ||
return { | ||
batch, | ||
batchCalls, | ||
batch: (callback) => { | ||
let result; | ||
transactions++; | ||
try { | ||
result = callback(); | ||
} finally { | ||
transactions--; | ||
if (!transactions) { | ||
flush(); | ||
} | ||
} | ||
return result; | ||
}, | ||
/** | ||
* All calls to the wrapped function will be batched. | ||
*/ | ||
batchCalls: (callback) => { | ||
return (...args) => { | ||
schedule(() => { | ||
callback(...args); | ||
}); | ||
}; | ||
}, | ||
schedule, | ||
setNotifyFunction, | ||
setBatchNotifyFunction, | ||
setScheduler | ||
/** | ||
* Use this method to set a custom notify function. | ||
* This can be used to for example wrap notifications with `React.act` while running tests. | ||
*/ | ||
setNotifyFunction: (fn) => { | ||
notifyFn = fn; | ||
}, | ||
/** | ||
* Use this method to set a custom function to batch notifications together into a single tick. | ||
* By default React Query will use the batch function provided by ReactDOM or React Native. | ||
*/ | ||
setBatchNotifyFunction: (fn) => { | ||
batchNotifyFn = fn; | ||
}, | ||
setScheduler: (fn) => { | ||
scheduleFn = fn; | ||
} | ||
}; | ||
@@ -74,0 +80,0 @@ } |
{ | ||
"name": "@tanstack/query-core", | ||
"version": "5.55.3", | ||
"version": "5.55.4", | ||
"description": "The framework agnostic core that powers TanStack Query", | ||
@@ -5,0 +5,0 @@ "author": "tannerlinsley", |
@@ -24,20 +24,2 @@ // TYPES | ||
const setScheduler = (fn: ScheduleFunction) => { | ||
scheduleFn = fn | ||
} | ||
const batch = <T>(callback: () => T): T => { | ||
let result | ||
transactions++ | ||
try { | ||
result = callback() | ||
} finally { | ||
transactions-- | ||
if (!transactions) { | ||
flush() | ||
} | ||
} | ||
return result | ||
} | ||
const schedule = (callback: NotifyCallback): void => { | ||
@@ -52,16 +34,2 @@ if (transactions) { | ||
} | ||
/** | ||
* All calls to the wrapped function will be batched. | ||
*/ | ||
const batchCalls = <T extends Array<unknown>>( | ||
callback: BatchCallsCallback<T>, | ||
): BatchCallsCallback<T> => { | ||
return (...args) => { | ||
schedule(() => { | ||
callback(...args) | ||
}) | ||
} | ||
} | ||
const flush = (): void => { | ||
@@ -81,25 +49,46 @@ const originalQueue = queue | ||
/** | ||
* Use this method to set a custom notify function. | ||
* This can be used to for example wrap notifications with `React.act` while running tests. | ||
*/ | ||
const setNotifyFunction = (fn: NotifyFunction) => { | ||
notifyFn = fn | ||
} | ||
/** | ||
* Use this method to set a custom function to batch notifications together into a single tick. | ||
* By default React Query will use the batch function provided by ReactDOM or React Native. | ||
*/ | ||
const setBatchNotifyFunction = (fn: BatchNotifyFunction) => { | ||
batchNotifyFn = fn | ||
} | ||
return { | ||
batch, | ||
batchCalls, | ||
batch: <T>(callback: () => T): T => { | ||
let result | ||
transactions++ | ||
try { | ||
result = callback() | ||
} finally { | ||
transactions-- | ||
if (!transactions) { | ||
flush() | ||
} | ||
} | ||
return result | ||
}, | ||
/** | ||
* All calls to the wrapped function will be batched. | ||
*/ | ||
batchCalls: <T extends Array<unknown>>( | ||
callback: BatchCallsCallback<T>, | ||
): BatchCallsCallback<T> => { | ||
return (...args) => { | ||
schedule(() => { | ||
callback(...args) | ||
}) | ||
} | ||
}, | ||
schedule, | ||
setNotifyFunction, | ||
setBatchNotifyFunction, | ||
setScheduler, | ||
/** | ||
* Use this method to set a custom notify function. | ||
* This can be used to for example wrap notifications with `React.act` while running tests. | ||
*/ | ||
setNotifyFunction: (fn: NotifyFunction) => { | ||
notifyFn = fn | ||
}, | ||
/** | ||
* Use this method to set a custom function to batch notifications together into a single tick. | ||
* By default React Query will use the batch function provided by ReactDOM or React Native. | ||
*/ | ||
setBatchNotifyFunction: (fn: BatchNotifyFunction) => { | ||
batchNotifyFn = fn | ||
}, | ||
setScheduler: (fn: ScheduleFunction) => { | ||
scheduleFn = fn | ||
}, | ||
} as const | ||
@@ -106,0 +95,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2038344
28946