UNPKG

@angular/cdk

Version:

Angular Material Component Development Kit

46 lines (45 loc) 1.91 kB
import { NgZone, OnDestroy } from '@angular/core'; import { Observable } from 'rxjs'; import { MediaMatcher } from './media-matcher'; import * as i0 from "@angular/core"; /** The current state of a layout breakpoint. */ export interface BreakpointState { /** Whether the breakpoint is currently matching. */ matches: boolean; /** * A key boolean pair for each query provided to the observe method, * with its current matched state. */ breakpoints: { [key: string]: boolean; }; } /** Utility for checking the matching state of @media queries. */ export declare class BreakpointObserver implements OnDestroy { private _mediaMatcher; private _zone; /** A map of all media queries currently being listened for. */ private _queries; /** A subject for all other observables to takeUntil based on. */ private readonly _destroySubject; constructor(_mediaMatcher: MediaMatcher, _zone: NgZone); /** Completes the active subject, signalling to all other observables to complete. */ ngOnDestroy(): void; /** * Whether one or more media queries match the current viewport size. * @param value One or more media queries to check. * @returns Whether any of the media queries match. */ isMatched(value: string | readonly string[]): boolean; /** * Gets an observable of results for the given queries that will emit new results for any changes * in matching of the given queries. * @param value One or more media queries to check. * @returns A stream of matches for the given queries. */ observe(value: string | readonly string[]): Observable<BreakpointState>; /** Registers a specific query to be listened for. */ private _registerQuery; static ɵfac: i0.ɵɵFactoryDeclaration<BreakpointObserver, never>; static ɵprov: i0.ɵɵInjectableDeclaration<BreakpointObserver>; }