Skip to content

Commit 07d4796

Browse files
committed
fix: align notify terminology
1 parent 1f5b13e commit 07d4796

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

jest.setup.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { act } from '@testing-library/react'
22

3-
import { setUpdateFn } from './src'
3+
import { setNotifyFn } from './src'
44

5-
// Wrap updates with act to make sure React knows about React Query updates
6-
setUpdateFn(fn => {
5+
// Wrap notifications with act to make sure React knows about React Query updates
6+
setNotifyFn(fn => {
77
act(fn)
88
})

src/core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export { QueryCache } from './queryCache'
22
export { QueryClient } from './queryClient'
3-
export { setBatchUpdatesFn, setUpdateFn } from './notifyManager'
3+
export { setBatchNotifyFn, setNotifyFn } from './notifyManager'
44
export { setLogger } from './logger'
55
export { setFocusHandler } from './focusHandler'
66
export { setOnlineHandler } from './onlineHandler'

src/core/notifyManager.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,36 @@ import { scheduleMicrotask } from './utils'
44

55
type NotifyCallback = () => void
66

7-
type UpdateFunction = (callback: () => void) => void
7+
type NotifyFunction = (callback: () => void) => void
88

9-
type BatchUpdatesFunction = (callback: () => void) => void
9+
type BatchNotifyFunction = (callback: () => void) => void
1010

1111
// GETTERS AND SETTERS
1212

13-
// Default to a dummy "update" implementation that just runs the callback
14-
let updateFn: UpdateFunction = (callback: () => void) => {
13+
// Default to a dummy "notify" implementation that just runs the callback
14+
let notifyFn: NotifyFunction = (callback: () => void) => {
1515
callback()
1616
}
1717

18-
// Default to a dummy "batch update" implementation that just runs the callback
19-
let batchUpdatesFn: BatchUpdatesFunction = (callback: () => void) => {
18+
// Default to a dummy "batch notify" implementation that just runs the callback
19+
let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {
2020
callback()
2121
}
2222

2323
/**
24-
* Use this function to set a custom update function.
25-
* This can be used to for example wrap updates with `React.act` while running tests.
24+
* Use this function to set a custom notify function.
25+
* This can be used to for example wrap notifications with `React.act` while running tests.
2626
*/
27-
export function setUpdateFn(fn: UpdateFunction) {
28-
updateFn = fn
27+
export function setNotifyFn(fn: NotifyFunction) {
28+
notifyFn = fn
2929
}
3030

3131
/**
32-
* Use this function to set a custom batch function to batch updates together into a single render pass.
32+
* Use this function to set a custom function to batch notifications together into a single tick.
3333
* By default React Query will use the batch function provided by ReactDOM or React Native.
3434
*/
35-
export function setBatchUpdatesFn(fn: BatchUpdatesFunction) {
36-
batchUpdatesFn = fn
35+
export function setBatchNotifyFn(fn: BatchNotifyFunction) {
36+
batchNotifyFn = fn
3737
}
3838

3939
// CLASS
@@ -57,12 +57,12 @@ class NotifyManager {
5757
return result
5858
}
5959

60-
schedule(notify: NotifyCallback): void {
60+
schedule(callback: NotifyCallback): void {
6161
if (this.transactions) {
62-
this.queue.push(notify)
62+
this.queue.push(callback)
6363
} else {
6464
scheduleMicrotask(() => {
65-
updateFn(notify)
65+
notifyFn(callback)
6666
})
6767
}
6868
}
@@ -72,9 +72,9 @@ class NotifyManager {
7272
this.queue = []
7373
if (queue.length) {
7474
scheduleMicrotask(() => {
75-
batchUpdatesFn(() => {
76-
queue.forEach(notify => {
77-
updateFn(notify)
75+
batchNotifyFn(() => {
76+
queue.forEach(callback => {
77+
notifyFn(callback)
7878
})
7979
})
8080
})

src/react/setBatchUpdatesFn.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { setBatchUpdatesFn } from '../core'
1+
import { setBatchNotifyFn } from '../core'
22
import { unstable_batchedUpdates } from './reactBatchedUpdates'
33

4-
setBatchUpdatesFn(unstable_batchedUpdates)
4+
setBatchNotifyFn(unstable_batchedUpdates)

0 commit comments

Comments
 (0)