1 | import type { StoreEnhancer } from 'redux';
|
2 | export declare const SHOULD_AUTOBATCH = "RTK_autoBatch";
|
3 | export declare const prepareAutoBatched: <T>() => (payload: T) => {
|
4 | payload: T;
|
5 | meta: unknown;
|
6 | };
|
7 | export declare type AutoBatchOptions = {
|
8 | type: 'tick';
|
9 | } | {
|
10 | type: 'timer';
|
11 | timeout: number;
|
12 | } | {
|
13 | type: 'raf';
|
14 | } | {
|
15 | type: 'callback';
|
16 | queueNotification: (notify: () => void) => void;
|
17 | };
|
18 | /**
|
19 | * A Redux store enhancer that watches for "low-priority" actions, and delays
|
20 | * notifying subscribers until either the queued callback executes or the
|
21 | * next "standard-priority" action is dispatched.
|
22 | *
|
23 | * This allows dispatching multiple "low-priority" actions in a row with only
|
24 | * a single subscriber notification to the UI after the sequence of actions
|
25 | * is finished, thus improving UI re-render performance.
|
26 | *
|
27 | * Watches for actions with the `action.meta[SHOULD_AUTOBATCH]` attribute.
|
28 | * This can be added to `action.meta` manually, or by using the
|
29 | * `prepareAutoBatched` helper.
|
30 | *
|
31 | * By default, it will queue a notification for the end of the event loop tick.
|
32 | * However, you can pass several other options to configure the behavior:
|
33 | * - `{type: 'tick'}: queues using `queueMicrotask` (default)
|
34 | * - `{type: 'timer, timeout: number}`: queues using `setTimeout`
|
35 | * - `{type: 'raf'}`: queues using `requestAnimationFrame`
|
36 | * - `{type: 'callback', queueNotification: (notify: () => void) => void}: lets you provide your own callback
|
37 | *
|
38 | *
|
39 | */
|
40 | export declare const autoBatchEnhancer: (options?: AutoBatchOptions) => StoreEnhancer;
|