Skip to content

Commit 9ccfc13

Browse files
author
Bobby
authored
perf: on multiple changes, batch reprocessing at the end
perf: on multiple changes, batch reprocessing at the end
2 parents 1782a3b + f274188 commit 9ccfc13

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
@@ -659,7 +659,9 @@ const modify = (state, { action, key, path }) =>
659659
}
660660

661661
// reprocessing unifies any order changes from firestore
662-
reprocessQuerires(draft, path);
662+
if (action.meta.reprocess !== false) {
663+
reprocessQuerires(draft, path);
664+
}
663665

664666
done();
665667
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)