Check and listen to all page activity changes. Combines several different methods for detecting activity changes into one to ensure maximum coverage.
The following are covered:
npm i page-active
Use listenToPageActivation to setup a page activation listener. You can setup multiple listeners without any issues.
import {listenToPageActivation} from 'page-active';
listenToPageActivation(
/**
* Pass in `true` here to fire your callback immediately when it is hooked up so you get an
* initial value.
*
* Pass in `false` to only fire your callback on future changes.
*/
true,
(isActive) => console.info(isActive),
);
At any time you can also call isPageActive to get the current page activation:
import {isPageActive} from 'page-active';
console.info(isPageActive());