NetworkStatus
NetworkStatus keeps browser connectivity state in the store.
What it tracks
The networkStatus entity keeps:
isSupported— whether the browser exposesnavigator.onLineisOnline— whether the browser is currently onlineisWatching— whether the online/offline listeners are active
Usage
javascript
import { createStore } from "@inglorious/store"
import { NetworkStatus } from "@inglorious/web/sensors/network-status"
const store = createStore({
types: { NetworkStatus },
autoCreateEntities: true,
})
const networkStatus = store.getEntity("networkStatus")
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Example
javascript
const online = networkStatus.isOnline
if (!online) {
console.warn("App is offline")
}
1
2
3
4
2
3
4
Inglorious Web