Skip to content

Instantly share code, notes, and snippets.

@MarsiBarsi
Last active March 23, 2021 14:50
Show Gist options
  • Save MarsiBarsi/118c6aedb0ea7c80cdd3ecfa08d61bfb to your computer and use it in GitHub Desktop.
Save MarsiBarsi/118c6aedb0ea7c80cdd3ecfa08d61bfb to your computer and use it in GitHub Desktop.
rxjs pageVisibility$
const pageVisibility$ = fromEvent(documentRef, 'visibilitychange').pipe(
startWith(0),
map(() => documentRef.visibilityState !== 'hidden'),
distinctUntilChanged(),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment