1.0.1 • Published 8 years ago

ember-connection-status v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

Ember-connection-status

Demo

Convenience tool I threw together from this gist

Instructions

  • ember install ember-connection-status
  • In either a controller, route, or component add the following:

Here's the application route as an example.

import Ember from 'ember';

export default Ember.Route.extend({
  connectionStatus: Ember.inject.service(),
  init () {
    this._super(...arguments)
    let connection = this.get('connectionStatus')
    //pass this instance to connectionStatus service.
    //allows for action hooks to fire here.
    connection.setup(this)
  },
  status: Ember.computed('connectionStatus.online', function () {
    return this.get('connectionStatus.online')
      ? 'Online' : 'Offline'
  }),
  actions: {
    online (event) {
      this.notifications.success(event.type, {
        autoClear: true,
        clearDuration: 1000
      });
    },
    offline (event) {
      this.notifications.error(event.type, {
        autoClear: true,
        clearDuration: 1000
      });
    }
  }
});

You can also access the network status via the connection.online property. If you choose you can observe changes, or create a computed property based on it.

Installation

  • git clone this repository
  • npm install
  • bower install

Try it yourself

Clone the repo, go through the installation process, and serve it up.