Creates an observable that emits when the [page visibility]https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API changes. It also emits the current visibility immediately upon subscription.
isPageVisible$().subscribe((isVisible) => { if (isVisible) { console.log('Page is visible'); } else { console.log('Page is hidden'); }}); Copy
isPageVisible$().subscribe((isVisible) => { if (isVisible) { console.log('Page is visible'); } else { console.log('Page is hidden'); }});
Note that for Angular projects, there is a harness available to help with tests that use this function in @s-libs/ng-dev.
@s-libs/ng-dev
Creates an observable that emits when the [page visibility]https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API changes. It also emits the current visibility immediately upon subscription.
Note that for Angular projects, there is a harness available to help with tests that use this function in
@s-libs/ng-dev
.