@studiohyperdrive/ngx-utils
Version:
A series of abstracts, utils, pipes and services for Angular applications.
47 lines (46 loc) • 1.92 kB
TypeScript
import { OnDestroy } from '@angular/core';
import { Observable } from 'rxjs';
import { NgxWindowService } from '@studiohyperdrive/ngx-core';
import * as i0 from "@angular/core";
/**
* A service that can be used to track media queries and their changes. It exposes a method
* to register media queries, which takes an array of tuples with the id of the media query
* and the query itself. The service will then emit the id of the media query that has
* changed when subscribed to the `getMatchingQuery$` method.
*/
export declare class NgxMediaQueryService implements OnDestroy {
private readonly windowService;
/**
* A map of media queries that are registered with the service.
*/
private readonly queryListMap;
/**
* A map of the registered media queries with their id.
*/
private readonly queryIdMap;
private readonly mediaQueryListenerMap;
/**
* A subject that emits the id of the media query that has changed.
*/
private readonly queryChangedSubject;
constructor(windowService: NgxWindowService);
/**
* Register a list of media queries that need to be tracked by the service.
*
* @param queries - A list of media queries that should be registered with the service.
*/
registerMediaQueries(...queries: [id: string, query: string][]): void;
/**
* Pass the id of the query whose changes need to be listened to.
*
* @param id - The id of the media query that should be checked.
* @returns An observable that emits a boolean value whenever the requested media query changes.
*/
getMatchingQuery$(id: string): Observable<boolean>;
/**
* Unregister all media query subscriptions from the service.
*/
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxMediaQueryService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<NgxMediaQueryService>;
}