Skip to content

refactor: clean up deprecated uses of combineLatest #17168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cdk-experimental/popover-edit/edit-event-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ export class EditEventDispatcher {
);

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

/** The combined set of row hover content states organized by row. */
private readonly _hoveredContentStateDistinct = combineLatest(
private readonly _hoveredContentStateDistinct = combineLatest([
this._getFirstRowWithHoverContent(),
this._getLastRowWithHoverContent(),
this.editingOrFocused,
Expand All @@ -116,7 +116,7 @@ export class EditEventDispatcher {
),
this._startWithNullDistinct,
),
).pipe(
]).pipe(
skip(1), // Skip the initial emission of [null, null, null, null].
map(computeHoverContentState),
distinctUntilChanged(areMapEntriesEqual),
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/table/table.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,7 @@ class FakeDataSource extends DataSource<TestData> {

connect(collectionViewer: CollectionViewer) {
this.isConnected = true;
return combineLatest(this._dataChange, collectionViewer.viewChange)
return combineLatest([this._dataChange, collectionViewer.viewChange])
.pipe(map(data => data[0]));
}

Expand Down
2 changes: 1 addition & 1 deletion src/cdk/tree/tree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ class FakeDataSource extends DataSource<TestData> {
connect(collectionViewer: CollectionViewer): Observable<TestData[]> {
this.isConnected = true;

return combineLatest(this._dataChange, collectionViewer.viewChange).pipe(map(([data]) => {
return combineLatest([this._dataChange, collectionViewer.viewChange]).pipe(map(([data]) => {
this.treeControl.dataNodes = data;
return data;
}));
Expand Down
4 changes: 2 additions & 2 deletions src/google-maps/google-map/google-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export class GoogleMap implements OnChanges, OnInit, OnDestroy {

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

private _watchForOptionsChanges(
optionsChanges: Observable<google.maps.MapOptions>) {
combineLatest(this._googleMapChanges, optionsChanges)
combineLatest([this._googleMapChanges, optionsChanges])
.pipe(takeUntil(this._destroy))
.subscribe(([googleMap, options]) => {
googleMap.setOptions(options);
Expand Down
2 changes: 1 addition & 1 deletion src/google-maps/map-info-window/map-info-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class MapInfoWindow implements OnInit, OnDestroy {
}

private _combineOptions(): Observable<google.maps.InfoWindowOptions> {
return combineLatest(this._options, this._position).pipe(map(([options, position]) => {
return combineLatest([this._options, this._position]).pipe(map(([options, position]) => {
const combinedOptions: google.maps.InfoWindowOptions = {
...options,
position: position || options.position,
Expand Down
2 changes: 1 addition & 1 deletion src/google-maps/map-marker/map-marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export class MapMarker implements OnInit, OnDestroy {
}

private _combineOptions(): Observable<google.maps.MarkerOptions> {
return combineLatest(this._options, this._title, this._position, this._label, this._clickable)
return combineLatest([this._options, this._title, this._position, this._label, this._clickable])
.pipe(map(([options, title, position, label, clickable]) => {
const combinedOptions: google.maps.MarkerOptions = {
...options,
Expand Down
6 changes: 3 additions & 3 deletions src/material/table/table-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,13 @@ export class MatTableDataSource<T> extends DataSource<T> {
observableOf(null);
const dataStream = this._data;
// Watch for base data or filter changes to provide a filtered set of data.
const filteredData = combineLatest(dataStream, this._filter)
const filteredData = combineLatest([dataStream, this._filter])
.pipe(map(([data]) => this._filterData(data)));
// Watch for filtered data or sort changes to provide an ordered set of data.
const orderedData = combineLatest(filteredData, sortChange)
const orderedData = combineLatest([filteredData, sortChange])
.pipe(map(([data]) => this._orderData(data)));
// Watch for ordered data or page changes to provide a paged set of data.
const paginatedData = combineLatest(orderedData, pageChange)
const paginatedData = combineLatest([orderedData, pageChange])
.pipe(map(([data]) => this._pageData(data)));
// Watched for paged data changes and send the result to the table to render.
this._renderChangesSubscription.unsubscribe();
Expand Down
16 changes: 8 additions & 8 deletions src/youtube-player/youtube-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ function bindSizeToPlayer(
widthObs: Observable<number>,
heightObs: Observable<number>
) {
return combineLatest(playerObs, widthObs, heightObs)
return combineLatest([playerObs, widthObs, heightObs])
.subscribe(([player, width, height]) => player && player.setSize(width, height));
}

Expand All @@ -391,10 +391,10 @@ function bindSuggestedQualityToPlayer(
playerObs: Observable<YT.Player | undefined>,
suggestedQualityObs: Observable<YT.SuggestedVideoQuality | undefined>
) {
return combineLatest(
return combineLatest([
playerObs,
suggestedQualityObs
).subscribe(
]).subscribe(
([player, suggestedQuality]) =>
player && suggestedQuality && player.setPlaybackQuality(suggestedQuality));
}
Expand Down Expand Up @@ -452,11 +452,11 @@ function createPlayerObservable(
const playerOptions =
videoIdObs
.pipe(
withLatestFrom(combineLatest(widthObs, heightObs)),
withLatestFrom(combineLatest([widthObs, heightObs])),
map(([videoId, [width, height]]) => videoId ? ({videoId, width, height, events}) : undefined),
);

return combineLatest(youtubeContainer, playerOptions)
return combineLatest([youtubeContainer, playerOptions])
.pipe(
skipUntilRememberLatest(iframeApiAvailableObs),
scan(syncPlayerState, undefined),
Expand Down Expand Up @@ -505,7 +505,7 @@ function bindCueVideoCall(
suggestedQualityObs: Observable<YT.SuggestedVideoQuality | undefined>,
destroyed: Observable<undefined>,
) {
const cueOptionsObs = combineLatest(startSecondsObs, endSecondsObs)
const cueOptionsObs = combineLatest([startSecondsObs, endSecondsObs])
.pipe(map(([startSeconds, endSeconds]) => ({startSeconds, endSeconds})));

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

merge(changedPlayer, changedVideoId, filteredCueOptions)
.pipe(
withLatestFrom(combineLatest(playerObs, videoIdObs, cueOptionsObs, suggestedQualityObs)),
withLatestFrom(combineLatest([playerObs, videoIdObs, cueOptionsObs, suggestedQualityObs])),
map(([_, values]) => values),
takeUntil(destroyed),
)
Expand Down