Skip to content

Commit e8fc304

Browse files
Merge pull request #5 from SachaZvetelman/download-speeds
Download speeds
2 parents ba0aab9 + ab8dd87 commit e8fc304

File tree

19 files changed

+228
-867
lines changed

19 files changed

+228
-867
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ yarn-error.log*
1919
*.njsproj
2020
*.sln
2121
*.sw?
22+
coverage/

.prettierrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
"printWidth": 120
2+
"printWidth": 110
33
}

README.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,16 @@ Add it globally:
3232
```
3333
import ConnectionAware from 'vue-connection-aware';
3434
35-
Vue.use(ConnectionAware);
35+
// Using default options.
36+
Vue.use(ConnectionAware);
37+
38+
// Or specifying the different category thresholds.
39+
Vue.use(ConnectionAware, {
40+
connectionCategoryThreshold: {
41+
slow: 1,
42+
medium: 3
43+
}
44+
});
3645
```
3746

3847
or import it directly into your component:
@@ -48,6 +57,19 @@ export default {
4857
};
4958
```
5059

60+
### Connection category thresholds
61+
62+
The default connection category thresholds, in Mbps, are:
63+
```
64+
slow: 2,
65+
medium: 6,
66+
fast: Number.MAX_SAFE_INTEGER
67+
```
68+
69+
This means that any download speed up to 2 Mbps, will be considered as `slow`. Any connection above 2 Mbps up to 6 Mbps will be considered as `medium`. Anything above that will be `fast`. You can override these defaults by specifying the defaults when installing the component as a plugin.
70+
71+
Each web application will have different requirements, and that's why you can configure the different thresholds.
72+
5173
## ⌨️ Usage
5274

5375
Wrap the DOM element you want to render for a specific effective connection type with the component markup:
@@ -66,10 +88,10 @@ _Note: if no speed prop (i.e. `slow`, `medium` or `fast`) is specified, the comp
6688

6789
| Name | Type | Required | Default | Description |
6890
| ---------- | --------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
69-
| `fast` | `Boolean` | `false` | `false` | Render the component when the effective type is `4g` |
70-
| `medium` | `Boolean` | `false` | `false` | Render the component when the effective type is `3g` |
71-
| `slow` | `Boolean` | `false` | `false` | Render the component when the effective type is `2g` or `slow-2g` |
72-
| `reactive` | `Boolean` | `false` | `true` | The component reacts to changes in the connection (e.g. if a component was initially rendered with a `4g` connection, hide it if the connection drops to `3g`) |
91+
| `fast` | `Boolean` | `false` | `false` | Render the component when the download speed is greater than the `medium` connection threshold |
92+
| `medium` | `Boolean` | `false` | `false` | Render the component when the download speed is greater than the `slow` connection threshold and less than or equal to the `medium` connection threshold |
93+
| `slow` | `Boolean` | `false` | `false` | Render the component when the download speed is less than or equal to the `slow` connection threshold |
94+
| `reactive` | `Boolean` | `false` | `true` | The component reacts to changes in the connection (e.g. if a component was initially rendered with a `fast` connection, hide it if the connection drops to `medium`) |
7395
| `online` | `Boolean` | `false` | `true` | Render the component when its online status matches this property (e.g. if `false`, the component will render only when the browser is offline) |
7496

7597
## 🧪 Common examples

coverage/clover.xml

Lines changed: 0 additions & 34 deletions
This file was deleted.

coverage/coverage-final.json

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)