Skip to content

Commit

Permalink
fix whenOffline functionlity
Browse files Browse the repository at this point in the history
  • Loading branch information
linediconsine committed Aug 28, 2021
1 parent fb9b7fe commit d0e61f5
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 40 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ yarn add amioffline
This module has an UMD bundle available through JSDelivr and Unpkg CDNs.

```html
<!-- For UNPKG use the code below. -->
<script src="https://unpkg.com/amioffline"></script>

<!-- For JSDelivr use the code below. -->
<script src="https://cdn.jsdelivr.net/npm/amioffline"></script>
<script src="https://cdn.jsdelivr.net/gh/linediconsine/amIoffline/dist/index.mjs"></script>

<script>
// UMD module is exposed through the "[libraryCamelCaseName]" global variable.
console.log(amioffline);
import aio from "./aio.js";
aio.whenOffline(alert('OFFLINE'))
</script>
```

Expand Down
8 changes: 4 additions & 4 deletions dist/index.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* aio v0.0.0
* (c) [authorFullName]
* amioffline v0.0.1
* (c) undefined
* Released under the MIT License.
*/

Expand Down Expand Up @@ -32,13 +32,13 @@ var aio = /** @class */ (function () {
aio.whenOffline = function (callback) {
var _this = this;
setInterval(function () {
if (_this.amIonline()) {
if (!_this.amIonline()) {
callback();
}
}, 400);
};
return aio;
}());

exports.default = aio;
exports.aio = aio;
//# sourceMappingURL=index.cjs.map
2 changes: 1 addition & 1 deletion dist/index.cjs.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions dist/index.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.esm.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions dist/index.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* aio v0.0.0
* (c) [authorFullName]
* amioffline v0.0.1
* (c) undefined
* Released under the MIT License.
*/

Expand Down Expand Up @@ -28,13 +28,13 @@ var aio = /** @class */ (function () {
aio.whenOffline = function (callback) {
var _this = this;
setInterval(function () {
if (_this.amIonline()) {
if (!_this.amIonline()) {
callback();
}
}, 400);
};
return aio;
}());

export default aio;
export { aio };
//# sourceMappingURL=index.mjs.map
2 changes: 1 addition & 1 deletion dist/index.mjs.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions dist/index.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.umd.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dist/index.umd.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.umd.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@
* ```
* @param void
*/
class aio {
export class aio {
static amIonline(): boolean {
return navigator.onLine;
}

static whenOffline(callback: () => void): void {
setInterval(() => {
if (this.amIonline()) {
if (!this.amIonline()) {
callback();
}
}, 400);
}
}

export default aio;
3 changes: 1 addition & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
* ```
* @param void
*/
declare class aio {
export declare class aio {
static amIonline(): boolean;
static whenOffline(callback: () => void): void;
}
export default aio;
//# sourceMappingURL=index.d.ts.map
2 changes: 1 addition & 1 deletion types/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d0e61f5

Please sign in to comment.