Skip to content

Commit 35f7e6d

Browse files
committed
Switch autobatch default method to 'raf'
1 parent 48fe9e1 commit 35f7e6d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

docs/api/autoBatchEnhancer.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ hide_title: true
99

1010
# `autoBatchEnhancer`
1111

12-
A Redux store enhancer that looks for one or more "low-priority" dispatched actions in a row, and delays notifying subscribers until either the end of the current event loop tick or when the next "normal-priority" action is dispatched.
12+
A Redux store enhancer that looks for one or more "low-priority" dispatched actions in a row, and queues a callback to run subscriber notifications on a delay. It then notifies subscribers either when the queued callback runs, or when the next "normal-priority" action is dispatched, whichever is first.
1313

1414
## Basic Usage
1515

@@ -83,12 +83,12 @@ Any action that is tagged with `action.meta[SHOULD_AUTOBATCH] = true` will be tr
8383
8484
`autoBatchEnhancer` accepts options to configure how the notification callback is queued:
8585
86-
- `{type: 'tick'}: queues using `queueMicrotask` (default)
86+
- `{type: 'raf'}`: queues using `requestAnimationFrame` (default)
87+
- `{type: 'tick'}: queues using `queueMicrotask`
8788
- `{type: 'timer, timeout: number}`: queues using `setTimeout`
88-
- `{type: 'raf'}`: queues using `requestAnimationFrame`
89-
- `{type: 'callback', queueNotification: (notify: () => void) => void}: lets you provide your own callback
89+
- `{type: 'callback', queueNotification: (notify: () => void) => void}: lets you provide your own callback, such as a debounced or throttled function
9090
91-
The default behavior is to queue the notifications at the end of the current event loop using `queueMicrotask`.
91+
The default behavior is to queue the notifications using `requestAnimationFrame`.
9292
9393
The `SHOULD_AUTOBATCH` value is meant to be opaque - it's currently a string for simplicity, but could be a `Symbol` in the future.
9494

packages/toolkit/src/autoBatchEnhancer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const createQueueWithTimer = (timeout: number) => {
5858
*
5959
*/
6060
export const autoBatchEnhancer =
61-
(options: AutoBatchOptions = { type: 'tick' }): StoreEnhancer =>
61+
(options: AutoBatchOptions = { type: 'raf' }): StoreEnhancer =>
6262
(next) =>
6363
(...args) => {
6464
const store = next(...args)

0 commit comments

Comments
 (0)