page-active
Version:
Check and listen to all page visibility changes.
19 lines (18 loc) • 661 B
JavaScript
import { PageActiveObservable } from './page-active.observable.js';
const pageActiveObservable = new PageActiveObservable();
/**
* Listen to changes in page activation.
*
* @returns A callback used to remove the listener.
*/
export function listenToPageActivation(
/** If true, the callback will immediately be fired with whatever the current value is. */
fireImmediately,
/** This listener will be called any time the page activation changes. */
listener) {
return pageActiveObservable.listen(fireImmediately, listener);
}
/** Check if the current page is currently active. */
export function isPageActive() {
return pageActiveObservable.value;
}