Detects when the user connection goes down
ES6
import Down from 'down.js';
const down = new Down();
CDN
<script src="link/to/down.js"></script>
<script>
const down = new Down();
</script>
const down = new Down();
this.isOnline = !this.$down.isDown;
this.$down.on('online', () => {
this.isOnline = true;
});
this.$down.on('offline', () => {
this.isOnline = false;
});
This library requires a polyfill for fetch
.