Skip to content

Commit

Permalink
refactor(cdk/layout): remove unnecessary type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelss95 committed Aug 10, 2020
1 parent d954d98 commit d7e262c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/cdk/layout/breakpoints-observer.ts
Expand Up @@ -6,11 +6,11 @@
* found in the LICENSE file at https://angular.io/license
*/

import {coerceArray} from '@angular/cdk/coercion';
import {Injectable, NgZone, OnDestroy} from '@angular/core';
import {MediaMatcher} from './media-matcher';
import {combineLatest, concat, Observable, Subject, Observer} from 'rxjs';
import {combineLatest, concat, Observable, Observer, Subject} from 'rxjs';
import {debounceTime, map, skip, startWith, take, takeUntil} from 'rxjs/operators';
import {coerceArray} from '@angular/cdk/coercion';
import {MediaMatcher} from './media-matcher';


/** The current state of a layout breakpoint. */
Expand Down Expand Up @@ -80,14 +80,14 @@ export class BreakpointObserver implements OnDestroy {
stateObservable = concat(
stateObservable.pipe(take(1)),
stateObservable.pipe(skip(1), debounceTime(0)));
return stateObservable.pipe(map((breakpointStates: InternalBreakpointState[]) => {
return stateObservable.pipe(map(breakpointStates => {
const response: BreakpointState = {
matches: false,
breakpoints: {},
};
breakpointStates.forEach((state: InternalBreakpointState) => {
response.matches = response.matches || state.matches;
response.breakpoints[state.query] = state.matches;
breakpointStates.forEach(({matches, query}) => {
response.matches = response.matches || matches;
response.breakpoints[query] = matches;
});
return response;
}));
Expand All @@ -100,10 +100,10 @@ export class BreakpointObserver implements OnDestroy {
return this._queries.get(query)!;
}

const mql: MediaQueryList = this._mediaMatcher.matchMedia(query);
const mql = this._mediaMatcher.matchMedia(query);

// Create callback for match changes and add it is as a listener.
const queryObservable = new Observable<MediaQueryList>((observer: Observer<MediaQueryList>) => {
const queryObservable = new Observable((observer: Observer<MediaQueryList>) => {
// Listener callback methods are wrapped to be placed back in ngZone. Callbacks must be placed
// back into the zone because matchMedia is only included in Zone.js by loading the
// webapis-media-query.js file alongside the zone.js file. Additionally, some browsers do not
Expand All @@ -117,7 +117,7 @@ export class BreakpointObserver implements OnDestroy {
};
}).pipe(
startWith(mql),
map((nextMql: MediaQueryList) => ({query, matches: nextMql.matches})),
map(({matches}) => ({query, matches})),
takeUntil(this._destroySubject)
);

Expand All @@ -133,7 +133,7 @@ export class BreakpointObserver implements OnDestroy {
* separated.
*/
function splitQueries(queries: readonly string[]): readonly string[] {
return queries.map((query: string) => query.split(','))
.reduce((a1: string[], a2: string[]) => a1.concat(a2))
return queries.map(query => query.split(','))
.reduce((a1, a2) => a1.concat(a2))
.map(query => query.trim());
}

0 comments on commit d7e262c

Please sign in to comment.