Use react-redux's batch instead of react's
This commit is contained in:
parent
3190f95fac
commit
663cd77eac
6 changed files with 123 additions and 66 deletions
|
@ -31,6 +31,7 @@ export type BatcherOptionsType<ItemType> = {
|
|||
|
||||
export type BatcherType<ItemType> = {
|
||||
add: (item: ItemType) => void;
|
||||
removeAll: (needle: ItemType) => void;
|
||||
anyPending: () => boolean;
|
||||
onIdle: () => Promise<void>;
|
||||
flushAndWait: () => Promise<void>;
|
||||
|
@ -70,6 +71,10 @@ export function createBatcher<ItemType>(
|
|||
}
|
||||
}
|
||||
|
||||
function removeAll(needle: ItemType) {
|
||||
items = items.filter(item => item !== needle);
|
||||
}
|
||||
|
||||
function anyPending(): boolean {
|
||||
return queue.size > 0 || queue.pending > 0 || items.length > 0;
|
||||
}
|
||||
|
@ -108,6 +113,7 @@ export function createBatcher<ItemType>(
|
|||
|
||||
batcher = {
|
||||
add,
|
||||
removeAll,
|
||||
anyPending,
|
||||
onIdle,
|
||||
flushAndWait,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue