0.0.9 • Published 4 years ago
use-stream-state v0.0.9
use-stream-state
React-hooks with RXjs
Demo
- check is online - link
const useOnline = () => {
const [isOnline] = useStreamState(true, () =>
merge(
fromEvent(window, "online").pipe(mapTo(true)),
fromEvent(window, "offline").pipe(mapTo(false))
).pipe(
startWith(window.navigator.onLine),
share()
)
);
return isOnline;
}