Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/private-notify-schedule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/query-core': major
---

Remove `notifyManager.schedule` from the public API. To schedule a callback through the notify manager, use `notifyManager.batchCalls(callback)()`.
17 changes: 0 additions & 17 deletions packages/query-core/src/__tests__/notifyManager.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ describe('notifyManager', () => {
expectTypeOf<keyof ReturnType<typeof createNotifyManager>>().toEqualTypeOf<
| 'batch'
| 'batchCalls'
| 'schedule'
| 'setNotifyFunction'
| 'setBatchNotifyFunction'
| 'setScheduler'
Expand Down Expand Up @@ -127,22 +126,6 @@ describe('notifyManager', () => {
})
})

describe('schedule', () => {
it('should only accept a callback taking no arguments', () => {
const localNotifyManager = createNotifyManager()

expectTypeOf(localNotifyManager.schedule).parameters.toEqualTypeOf<
[callback: () => void]
>()
})

it('should return void', () => {
const localNotifyManager = createNotifyManager()

expectTypeOf(localNotifyManager.schedule).returns.toEqualTypeOf<void>()
})
})

describe('setNotifyFunction', () => {
it('should only accept a function taking a callback', () => {
const localNotifyManager = createNotifyManager()
Expand Down
14 changes: 7 additions & 7 deletions packages/query-core/src/__tests__/notifyManager.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('notifyManager', () => {
it('should notify in a microtask by default', async () => {
const notifyManagerTest = createNotifyManager()
const callbackSpy = vi.fn<() => void>()
notifyManagerTest.schedule(callbackSpy)
notifyManagerTest.batchCalls(callbackSpy)()
expect(callbackSpy).not.toHaveBeenCalled()
await Promise.resolve()
expect(callbackSpy).toHaveBeenCalledWith()
Expand All @@ -30,7 +30,7 @@ describe('notifyManager', () => {
const callbackBatchLevel2Spy = vi
.fn<() => void>()
.mockImplementation(() => {
notifyManagerTest.schedule(callbackScheduleSpy)
notifyManagerTest.batchCalls(callbackScheduleSpy)()
})
const callbackBatchLevel1Spy = vi
.fn<() => void>()
Expand All @@ -56,7 +56,7 @@ describe('notifyManager', () => {
notifyManagerTest.setScheduler(customCallback)
notifyManagerTest.setNotifyFunction(notifySpy)

notifyManagerTest.batch(() => notifyManagerTest.schedule(vi.fn))
notifyManagerTest.batch(notifyManagerTest.batchCalls(vi.fn))

expect(customCallback).toHaveBeenCalledTimes(1)
await vi.advanceTimersByTimeAsync(0)
Expand All @@ -71,7 +71,7 @@ describe('notifyManager', () => {

try {
notifyManagerTest.batch(() => {
notifyManagerTest.schedule(vi.fn)
notifyManagerTest.batchCalls(vi.fn)()
throw new Error('Foo')
})
} catch {}
Expand All @@ -89,8 +89,8 @@ describe('notifyManager', () => {
notifyManagerTest.setBatchNotifyFunction(batchNotifySpy)

notifyManagerTest.batch(() => {
notifyManagerTest.schedule(callbackSpy1)
notifyManagerTest.schedule(callbackSpy2)
notifyManagerTest.batchCalls(callbackSpy1)()
notifyManagerTest.batchCalls(callbackSpy2)()
})

await vi.advanceTimersByTimeAsync(0)
Expand Down Expand Up @@ -142,7 +142,7 @@ describe('notifyManager', () => {
const notifyManagerCallbackSpy = vi.fn<() => void>()

defaultScheduler(defaultSchedulerCallbackSpy)
notifyManager.schedule(notifyManagerCallbackSpy)
notifyManager.batchCalls(notifyManagerCallbackSpy)()

expect(queueMicrotaskSpy).toHaveBeenCalledTimes(2)
expect(queueMicrotaskSpy).toHaveBeenNthCalledWith(
Expand Down
5 changes: 0 additions & 5 deletions packages/query-core/src/notifyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ export function createNotifyManager() {
})
}
},
/**
* Schedules a function to be run on the next batch.
* By default, the batch runs in a microtask. Use `setScheduler` to change when it runs.
*/
schedule,
/**
* Use this method to set a custom notify function.
* This can be used to for example wrap notifications with `React.act` while running tests.
Expand Down
1 change: 0 additions & 1 deletion packages/svelte-query/src/useMutationState.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export function useMutationState<
)
if (result.current !== nextResult) {
result = nextResult
//notifyManager.schedule(onStoreChange)
}
})
}) */
Expand Down
Loading