@@ -11,9 +11,10 @@ import {
11
11
isEmpty ,
12
12
isNil ,
13
13
map ,
14
- mergeAll ,
14
+ mergeWith ,
15
15
partition ,
16
16
pluck ,
17
+ reduce ,
17
18
values
18
19
} from 'ramda' ;
19
20
@@ -86,13 +87,15 @@ const observer: IStoreObserverDefinition<IStoreState> = {
86
87
1. Remove duplicated `requested` callbacks - give precedence to newer callbacks over older ones
87
88
*/
88
89
90
+ const [ rInitial , rLater ] = partition ( cb => cb . initialCall , requested ) ;
91
+
89
92
/*
90
93
Group callbacks by identifier and partition based on whether there are duplicates or not.
91
94
*/
92
95
const [ rWithoutDuplicates , rWithDuplicates ] = partition ( rdg => rdg . length === 1 , values (
93
96
groupBy < ICallback > (
94
97
getUniqueIdentifier ,
95
- requested
98
+ rLater
96
99
)
97
100
) ) ;
98
101
@@ -106,7 +109,7 @@ const observer: IStoreObserverDefinition<IStoreState> = {
106
109
*/
107
110
const rMergedDuplicates = map ( group => assoc (
108
111
'changedPropIds' ,
109
- mergeAll ( pluck ( 'changedPropIds' , group ) ) ,
112
+ reduce ( mergeWith ( Math . max ) , { } , pluck ( 'changedPropIds' , group ) ) ,
110
113
group [ 0 ]
111
114
) , rWithDuplicates ) ;
112
115
@@ -115,7 +118,7 @@ const observer: IStoreObserverDefinition<IStoreState> = {
115
118
Clean up the `requested` list - during the dispatch phase,
116
119
duplicates will be removed for real
117
120
*/
118
- requested = concat ( flatten ( rWithoutDuplicates ) , rMergedDuplicates ) ;
121
+ requested = concat ( rInitial , concat ( flatten ( rWithoutDuplicates ) , rMergedDuplicates ) ) ;
119
122
120
123
/*
121
124
2. Remove duplicated `prioritized`, `executing` and `watching` callbacks
0 commit comments