Created
January 3, 2019 16:15
-
-
Save darrenmothersele/b59a95c0059d57452628f479d44b6afe to your computer and use it in GitHub Desktop.
NgRx Effect for App Online status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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