Skip to content

Commit a4c4718

Browse files
btecurunspired
authored andcommitted
[BUGFIX docs] Update 'navigator.connection' example to spec (#6060)
1 parent fc69c46 commit a4c4718

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

packages/adapter/addon/adapter.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,9 @@ export default EmberObject.extend({
614614
615615
```javascript
616616
shouldBackgroundReloadRecord(store, snapshot) {
617-
let connection = window.navigator.connection;
617+
let { downlink, effectiveType } = navigator.connection;
618618
619-
if (connection === 'cellular' || connection === 'none') {
620-
return false;
621-
} else {
622-
return true;
623-
}
619+
return downlink > 0 && effectiveType === '4g';
624620
}
625621
```
626622
@@ -654,13 +650,9 @@ export default EmberObject.extend({
654650
655651
```javascript
656652
shouldBackgroundReloadAll(store, snapshotArray) {
657-
let connection = window.navigator.connection;
653+
let { downlink, effectiveType } = navigator.connection;
658654
659-
if (connection === 'cellular' || connection === 'none') {
660-
return false;
661-
} else {
662-
return true;
663-
}
655+
return downlink > 0 && effectiveType === '4g';
664656
}
665657
```
666658

0 commit comments

Comments
 (0)