Skip to content

Instantly share code, notes, and snippets.

@darrenmothersele
Created January 3, 2019 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrenmothersele/b59a95c0059d57452628f479d44b6afe to your computer and use it in GitHub Desktop.
Save darrenmothersele/b59a95c0059d57452628f479d44b6afe to your computer and use it in GitHub Desktop.
NgRx Effect for App Online status
@Effect()
online$ = merge(
fromEvent(window, 'online').pipe(mapTo(true)),
fromEvent(window, 'offline').pipe(mapTo(false))
).pipe(
startWith(navigator.onLine),
map(isOnline => isOnline ? new AppIsOnline() : new AppIsOffline())
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment