File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -171,13 +171,25 @@ export class TimeSync implements TimeSyncApi {
171
171
this . #latestDateSnapshot = this . #createNewDatetime(
172
172
this . #latestDateSnapshot,
173
173
) ;
174
- this . #notifySubscriptions ( ) ;
174
+ this . #flushUpdateToSubscriptions ( ) ;
175
175
} , newFastestInterval ) ;
176
176
}
177
177
178
- #notifySubscriptions ( ) : void {
178
+ #flushUpdateToSubscriptions ( ) : void {
179
179
for ( const subEntry of this . #subscriptions) {
180
- subEntry . onUpdate ( this . #latestDateSnapshot) ;
180
+ if ( subEntry . select === undefined ) {
181
+ subEntry . onUpdate ( this . #latestDateSnapshot) ;
182
+ continue ;
183
+ }
184
+
185
+ // Keeping things simple by only comparing values React-style with ===.
186
+ // If that becomes a problem down the line, we can beef the class up
187
+ const prevSelection = this . #selectionCache. get ( subEntry . id ) ;
188
+ const newSelection = subEntry . select ( this . #latestDateSnapshot) ;
189
+ if ( prevSelection !== newSelection ) {
190
+ this . #selectionCache. set ( subEntry . id , newSelection ) ;
191
+ subEntry . onUpdate ( this . #latestDateSnapshot) ;
192
+ }
181
193
}
182
194
}
183
195
You can’t perform that action at this time.
0 commit comments