connection-state
Advanced tools
Comparing version
{ | ||
"name": "connection-state", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Detect online and offline network state.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -13,2 +13,18 @@ # Connection state [](https://www.npmjs.com/package/connection-state)  | ||
## Usage | ||
```js | ||
import { connectionState } from 'connection-state' | ||
const connection = connectionState() | ||
console.log(`You are ${connection.getState()}.`) | ||
// connection.getState() returns 'online' or 'offline' | ||
connection.addListener((state) => { | ||
console.log(`Your connection state has changed. You are now ${state}.`) | ||
}) | ||
// state is 'online' or 'offline' | ||
``` | ||
## Development | ||
@@ -15,0 +31,0 @@ |
15874
2.33%33
94.12%