Skip to content

Commit 9429a47

Browse files
crisbetommalerba
authored andcommitted
refactor: clean up deprecated uses of combineLatest (#17168)
The signature of `combineLatest` that uses individual parameters has been deprecated. These changes switch to the new recommended way which passes in the observables as an array. (cherry picked from commit 3961544)
1 parent bacb8df commit 9429a47

File tree

7 files changed

+22
-21
lines changed

7 files changed

+22
-21
lines changed

src/cdk-experimental/popover-edit/edit-event-dispatcher.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ export class EditEventDispatcher {
8282
);
8383

8484
/** An observable that emits the row containing focus or an active edit. */
85-
readonly editingOrFocused = combineLatest(
85+
readonly editingOrFocused = combineLatest([
8686
this.editing.pipe(
8787
map(cell => closest(cell, ROW_SELECTOR)),
8888
this._startWithNull,
8989
),
9090
this.focused.pipe(this._startWithNull),
91-
).pipe(
91+
]).pipe(
9292
map(([editingRow, focusedRow]) => focusedRow || editingRow),
9393
this._distinctUntilChanged as MonoTypeOperatorFunction<Element|null>,
9494
auditTime(FOCUS_DELAY), // Use audit to skip over blur events to the next focused element.
@@ -103,7 +103,7 @@ export class EditEventDispatcher {
103103
private _currentlyEditing: Element|null = null;
104104

105105
/** The combined set of row hover content states organized by row. */
106-
private readonly _hoveredContentStateDistinct = combineLatest(
106+
private readonly _hoveredContentStateDistinct = combineLatest([
107107
this._getFirstRowWithHoverContent(),
108108
this._getLastRowWithHoverContent(),
109109
this.editingOrFocused,
@@ -116,7 +116,7 @@ export class EditEventDispatcher {
116116
),
117117
this._startWithNullDistinct,
118118
),
119-
).pipe(
119+
]).pipe(
120120
skip(1), // Skip the initial emission of [null, null, null, null].
121121
map(computeHoverContentState),
122122
distinctUntilChanged(areMapEntriesEqual),

src/cdk/table/table.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,7 @@ class FakeDataSource extends DataSource<TestData> {
13961396

13971397
connect(collectionViewer: CollectionViewer) {
13981398
this.isConnected = true;
1399-
return combineLatest(this._dataChange, collectionViewer.viewChange)
1399+
return combineLatest([this._dataChange, collectionViewer.viewChange])
14001400
.pipe(map(data => data[0]));
14011401
}
14021402

src/cdk/tree/tree.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ class FakeDataSource extends DataSource<TestData> {
10101010
connect(collectionViewer: CollectionViewer): Observable<TestData[]> {
10111011
this.isConnected = true;
10121012

1013-
return combineLatest(this._dataChange, collectionViewer.viewChange).pipe(map(([data]) => {
1013+
return combineLatest([this._dataChange, collectionViewer.viewChange]).pipe(map(([data]) => {
10141014
this.treeControl.dataNodes = data;
10151015
return data;
10161016
}));

src/google-maps/google-map/google-map.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export class GoogleMap implements OnChanges, OnInit, AfterContentInit, OnDestroy
398398

399399
/** Combines the center and zoom and the other map options into a single object */
400400
private _combineOptions(): Observable<google.maps.MapOptions> {
401-
return combineLatest(this._options, this._center, this._zoom)
401+
return combineLatest([this._options, this._center, this._zoom])
402402
.pipe(map(([options, center, zoom]) => {
403403
const combinedOptions: google.maps.MapOptions = {
404404
...options,
@@ -420,7 +420,7 @@ export class GoogleMap implements OnChanges, OnInit, AfterContentInit, OnDestroy
420420

421421
private _watchForOptionsChanges(
422422
optionsChanges: Observable<google.maps.MapOptions>) {
423-
combineLatest(this._googleMapChanges, optionsChanges)
423+
combineLatest([this._googleMapChanges, optionsChanges])
424424
.pipe(takeUntil(this._destroy))
425425
.subscribe(([googleMap, options]) => {
426426
googleMap.setOptions(options);

src/google-maps/map-marker/map-marker.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,9 @@ export class MapMarker implements OnInit, OnDestroy {
338338
}
339339

340340
private _combineOptions(): Observable<google.maps.MarkerOptions> {
341-
return combineLatest(
342-
this._options, this._title, this._position, this._label, this._clickable, this._map)
341+
return combineLatest([
342+
this._options, this._title, this._position, this._label, this._clickable, this._map
343+
])
343344
.pipe(map(([options, title, position, label, clickable, googleMap]) => {
344345
const combinedOptions: google.maps.MarkerOptions = {
345346
...options,

src/material/table/table-data-source.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,13 @@ export class MatTableDataSource<T> extends DataSource<T> {
228228
observableOf(null);
229229
const dataStream = this._data;
230230
// Watch for base data or filter changes to provide a filtered set of data.
231-
const filteredData = combineLatest(dataStream, this._filter)
231+
const filteredData = combineLatest([dataStream, this._filter])
232232
.pipe(map(([data]) => this._filterData(data)));
233233
// Watch for filtered data or sort changes to provide an ordered set of data.
234-
const orderedData = combineLatest(filteredData, sortChange)
234+
const orderedData = combineLatest([filteredData, sortChange])
235235
.pipe(map(([data]) => this._orderData(data)));
236236
// Watch for ordered data or page changes to provide a paged set of data.
237-
const paginatedData = combineLatest(orderedData, pageChange)
237+
const paginatedData = combineLatest([orderedData, pageChange])
238238
.pipe(map(([data]) => this._pageData(data)));
239239
// Watched for paged data changes and send the result to the table to render.
240240
this._renderChangesSubscription.unsubscribe();

src/youtube-player/youtube-player.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ function bindSizeToPlayer(
382382
widthObs: Observable<number>,
383383
heightObs: Observable<number>
384384
) {
385-
return combineLatest(playerObs, widthObs, heightObs)
385+
return combineLatest([playerObs, widthObs, heightObs])
386386
.subscribe(([player, width, height]) => player && player.setSize(width, height));
387387
}
388388

@@ -391,10 +391,10 @@ function bindSuggestedQualityToPlayer(
391391
playerObs: Observable<YT.Player | undefined>,
392392
suggestedQualityObs: Observable<YT.SuggestedVideoQuality | undefined>
393393
) {
394-
return combineLatest(
394+
return combineLatest([
395395
playerObs,
396396
suggestedQualityObs
397-
).subscribe(
397+
]).subscribe(
398398
([player, suggestedQuality]) =>
399399
player && suggestedQuality && player.setPlaybackQuality(suggestedQuality));
400400
}
@@ -452,11 +452,11 @@ function createPlayerObservable(
452452
const playerOptions =
453453
videoIdObs
454454
.pipe(
455-
withLatestFrom(combineLatest(widthObs, heightObs)),
455+
withLatestFrom(combineLatest([widthObs, heightObs])),
456456
map(([videoId, [width, height]]) => videoId ? ({videoId, width, height, events}) : undefined),
457457
);
458458

459-
return combineLatest(youtubeContainer, playerOptions)
459+
return combineLatest([youtubeContainer, playerOptions])
460460
.pipe(
461461
skipUntilRememberLatest(iframeApiAvailableObs),
462462
scan(syncPlayerState, undefined),
@@ -505,7 +505,7 @@ function bindCueVideoCall(
505505
suggestedQualityObs: Observable<YT.SuggestedVideoQuality | undefined>,
506506
destroyed: Observable<undefined>,
507507
) {
508-
const cueOptionsObs = combineLatest(startSecondsObs, endSecondsObs)
508+
const cueOptionsObs = combineLatest([startSecondsObs, endSecondsObs])
509509
.pipe(map(([startSeconds, endSeconds]) => ({startSeconds, endSeconds})));
510510

511511
// Only respond to changes in cue options if the player is not running.
@@ -520,14 +520,14 @@ function bindCueVideoCall(
520520
// If the player changed, there's no reason to run 'cue' unless there are cue options.
521521
const changedPlayer = playerObs.pipe(
522522
filterOnOther(
523-
combineLatest(videoIdObs, cueOptionsObs),
523+
combineLatest([videoIdObs, cueOptionsObs]),
524524
([videoId, cueOptions], player) =>
525525
!!player &&
526526
(videoId != player.videoId || !!cueOptions.startSeconds || !!cueOptions.endSeconds)));
527527

528528
merge(changedPlayer, changedVideoId, filteredCueOptions)
529529
.pipe(
530-
withLatestFrom(combineLatest(playerObs, videoIdObs, cueOptionsObs, suggestedQualityObs)),
530+
withLatestFrom(combineLatest([playerObs, videoIdObs, cueOptionsObs, suggestedQualityObs])),
531531
map(([_, values]) => values),
532532
takeUntil(destroyed),
533533
)

0 commit comments

Comments
 (0)