ember-online-status

1.0.8 • Public • Published

ember-online-status

Ember addon for checking if Internet connection is up. Makes use of the is-online module, polling to check if the Internet is accessible.

Usage

  • ember install ember-online-status
  • Inject the service in either a controller, route, or component
  • onlineStatus.isCheckingConnection returns true when checking the connection status, false otherwise.
  • onlineStatus.isOnline returns true when the Internet is accessible, false otherwise.

Example:

import Ember from 'ember';

export default Ember.Controller.extend({
  onlineStatus: Ember.inject.service()
});
{{#if onlineStatus.isCheckingConnection}}
  Checking connection...
{{else}}
  {{#if onlineStatus.isOnline}}
    Online
  {{else}}
    Offline
  {{/if}}
{{/if}}

Configuring

Can add a configuration in the environment.js file

ENV.onlineStatus = {
  version: 'v4',
  pollInterval: 15000,
  timeout: 5000
};
pollInterval

Type: number Default: 15000

Milliseconds to wait before checking the connection status again.

timeout

Type: number Default: 5000

Milliseconds to wait for a server to respond.

version

Type: string Values: v4 v6 Default: v4

Internet Protocol version to use. This is an advanced option that is usually not necessary to be set, but it can prove useful to specifically assert IPv6 connectivity.

Installation

  • git clone https://github.com/AdamWard1995/ember-online-status.git
  • cd ember-online-status
  • npm install

Try yourself

Package Sidebar

Install

npm i ember-online-status

Weekly Downloads

1

Version

1.0.8

License

MIT

Last publish

Collaborators

  • adamward1995