@@ -4,36 +4,36 @@ import { scheduleMicrotask } from './utils'
4
4
5
5
type NotifyCallback = ( ) => void
6
6
7
- type UpdateFunction = ( callback : ( ) => void ) => void
7
+ type NotifyFunction = ( callback : ( ) => void ) => void
8
8
9
- type BatchUpdatesFunction = ( callback : ( ) => void ) => void
9
+ type BatchNotifyFunction = ( callback : ( ) => void ) => void
10
10
11
11
// GETTERS AND SETTERS
12
12
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 ) => {
15
15
callback ( )
16
16
}
17
17
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 ) => {
20
20
callback ( )
21
21
}
22
22
23
23
/**
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.
26
26
*/
27
- export function setUpdateFn ( fn : UpdateFunction ) {
28
- updateFn = fn
27
+ export function setNotifyFn ( fn : NotifyFunction ) {
28
+ notifyFn = fn
29
29
}
30
30
31
31
/**
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 .
33
33
* By default React Query will use the batch function provided by ReactDOM or React Native.
34
34
*/
35
- export function setBatchUpdatesFn ( fn : BatchUpdatesFunction ) {
36
- batchUpdatesFn = fn
35
+ export function setBatchNotifyFn ( fn : BatchNotifyFunction ) {
36
+ batchNotifyFn = fn
37
37
}
38
38
39
39
// CLASS
@@ -57,12 +57,12 @@ class NotifyManager {
57
57
return result
58
58
}
59
59
60
- schedule ( notify : NotifyCallback ) : void {
60
+ schedule ( callback : NotifyCallback ) : void {
61
61
if ( this . transactions ) {
62
- this . queue . push ( notify )
62
+ this . queue . push ( callback )
63
63
} else {
64
64
scheduleMicrotask ( ( ) => {
65
- updateFn ( notify )
65
+ notifyFn ( callback )
66
66
} )
67
67
}
68
68
}
@@ -72,9 +72,9 @@ class NotifyManager {
72
72
this . queue = [ ]
73
73
if ( queue . length ) {
74
74
scheduleMicrotask ( ( ) => {
75
- batchUpdatesFn ( ( ) => {
76
- queue . forEach ( notify => {
77
- updateFn ( notify )
75
+ batchNotifyFn ( ( ) => {
76
+ queue . forEach ( callback => {
77
+ notifyFn ( callback )
78
78
} )
79
79
} )
80
80
} )
0 commit comments