UNPKG

2.28 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { NgZone, OnDestroy } from '@angular/core';
9import { BehaviorSubject, Observable } from 'rxjs';
10import { MediaChange } from '../media-change';
11/**
12 * MediaMonitor configures listeners to mediaQuery changes and publishes an Observable facade to
13 * convert mediaQuery change callbacks to subscriber notifications. These notifications will be
14 * performed within the ng Zone to trigger change detections and component updates.
15 *
16 * NOTE: both mediaQuery activations and de-activations are announced in notifications
17 */
18export declare class MatchMedia implements OnDestroy {
19 protected _zone: NgZone;
20 protected _platformId: Object;
21 protected _document: any;
22 /** Initialize source with 'all' so all non-responsive APIs trigger style updates */
23 readonly source: BehaviorSubject<MediaChange>;
24 registry: Map<string, MediaQueryList>;
25 private readonly pendingRemoveListenerFns;
26 constructor(_zone: NgZone, _platformId: Object, _document: any);
27 /**
28 * Publish list of all current activations
29 */
30 get activations(): string[];
31 /**
32 * For the specified mediaQuery?
33 */
34 isActive(mediaQuery: string): boolean;
35 /**
36 * External observers can watch for all (or a specific) mql changes.
37 *
38 * If a mediaQuery is not specified, then ALL mediaQuery activations will
39 * be announced.
40 */
41 observe(): Observable<MediaChange>;
42 observe(mediaQueries: string[]): Observable<MediaChange>;
43 observe(mediaQueries: string[], filterOthers: boolean): Observable<MediaChange>;
44 /**
45 * Based on the BreakPointRegistry provider, register internal listeners for each unique
46 * mediaQuery. Each listener emits specific MediaChange data to observers
47 */
48 registerQuery(mediaQuery: string | string[]): MediaChange[];
49 ngOnDestroy(): void;
50 /**
51 * Call window.matchMedia() to build a MediaQueryList; which
52 * supports 0..n listeners for activation/deactivation
53 */
54 protected buildMQL(query: string): MediaQueryList;
55 protected _observable$: Observable<MediaChange>;
56}