Skip to content

Commit f274188

Browse files
committed
perf: on multiple changes, batch reprocessing at the end
1 parent f56439b commit f274188

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/reducers/cacheReducer.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,9 @@ const modify = (state, { action, key, path }) =>
655655
}
656656

657657
// reprocessing unifies any order changes from firestore
658-
reprocessQuerires(draft, path);
658+
if (action.meta.reprocess !== false) {
659+
reprocessQuerires(draft, path);
660+
}
659661

660662
done();
661663
return draft;

src/utils/query.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,9 @@ export function dispatchListenerResponse({
803803
if (docChanges && docChanges.length < docData.size) {
804804
// Loop to dispatch for each change if there are multiple
805805
// TODO: Option for dispatching multiple changes in single action
806-
docChanges.forEach((change) => {
807-
dispatch(docChangeEvent(change, meta));
806+
docChanges.forEach((change, index) => {
807+
const lastChange = index === docChanges.length - 1;
808+
dispatch(docChangeEvent(change, { reprocess: lastChange, ...meta }));
808809
});
809810
} else {
810811
// Dispatch action for whole collection change

0 commit comments

Comments
 (0)