UNPKG

@frshaw1/angular-visibility-api

Version:

An Angular and RxJS enabled event publisher for the browser's visibility API

30 lines (29 loc) 1.28 kB
import { Observable } from 'rxjs/Observable'; /** * VisibilityService * * An Angular service that utilizes RxJS Observables to publish events for the browsers visibility API. * This service abstracts the differences between browsers and makes using the visibility API seamless. * * The service exposes a single method `onVisibilityChange()` that will return an `Observable<Boolean>` that the * caller can subscribe to. Since the internal representation of the `Observable` is a `BehaviorSubject`, upon each * subscription the subscribe handler will be called immediately with the current value of the visibility observable. */ export declare class VisibilityService { private document; private hiddenProperty; private visibilityChangeEvent; private visibility$; private legacyVisibilityHandleFn; constructor(); /** * Generates the Observable<Boolean> that callers can subscribe to for visibility events. The subscription value * is a {Boolean} value that indicates whether the current window IS VISIBLE. * * @return {Observable<Boolean>} */ onVisibilityChange(): Observable<Boolean>; private initializeVisibilityParameters(); private setupVisibilityHandler(); private legacyVisibilityHandler(event); }