Skip to content

Commit 8b6ff26

Browse files
author
Marc-André Rivet
committed
- don't group initial callbacks with subsequent callbacks
- merge with max value (DIRECT, INDIRECT)
1 parent f795fdb commit 8b6ff26

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: dash-renderer/src/observers/requestedCallbacks.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import {
1111
isEmpty,
1212
isNil,
1313
map,
14-
mergeAll,
14+
mergeWith,
1515
partition,
1616
pluck,
17+
reduce,
1718
values
1819
} from 'ramda';
1920

@@ -86,13 +87,15 @@ const observer: IStoreObserverDefinition<IStoreState> = {
8687
1. Remove duplicated `requested` callbacks - give precedence to newer callbacks over older ones
8788
*/
8889

90+
const [rInitial, rLater] = partition(cb => cb.initialCall, requested);
91+
8992
/*
9093
Group callbacks by identifier and partition based on whether there are duplicates or not.
9194
*/
9295
const [rWithoutDuplicates, rWithDuplicates] = partition(rdg => rdg.length === 1, values(
9396
groupBy<ICallback>(
9497
getUniqueIdentifier,
95-
requested
98+
rLater
9699
)
97100
));
98101

@@ -106,7 +109,7 @@ const observer: IStoreObserverDefinition<IStoreState> = {
106109
*/
107110
const rMergedDuplicates = map(group => assoc(
108111
'changedPropIds',
109-
mergeAll(pluck('changedPropIds', group)),
112+
reduce(mergeWith(Math.max), {}, pluck('changedPropIds', group)),
110113
group[0]
111114
), rWithDuplicates);
112115

@@ -115,7 +118,7 @@ const observer: IStoreObserverDefinition<IStoreState> = {
115118
Clean up the `requested` list - during the dispatch phase,
116119
duplicates will be removed for real
117120
*/
118-
requested = concat(flatten(rWithoutDuplicates), rMergedDuplicates);
121+
requested = concat(rInitial, concat(flatten(rWithoutDuplicates), rMergedDuplicates));
119122

120123
/*
121124
2. Remove duplicated `prioritized`, `executing` and `watching` callbacks

0 commit comments

Comments
 (0)