@elemental-concept/offline-monitor
TypeScript icon, indicating that this package has built-in type declarations

0.8.2 • Public • Published

Offline Monitor Service For Angular

Provides an Observable to monitor application network state as provided by online and offline events. If API is not supported by the environment, supported flag is set to false and state emits false.

Installation

Install through npm:

$ npm i @elemental-concept/offline-monitor

or yarn:

$ yarn add @elemental-concept/offline-monitor

Usage

Import OfflineMonitorModule inside one of your Angular modules or inside AppModule if you want to make it globally available. Inject into your component or service OfflineMonitorService and subscribe to state changes.

import { Component, OnInit } from '@angular/core';

import { OfflineMonitorService } from '@elemental-concept/offline-monitor';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.scss' ]
})
export class AppComponent implements OnInit {
  online: boolean;

  constructor(private readonly offlineMonitor: OfflineMonitorService) {
  }

  ngOnInit() {
    this.offlineMonitor
      .state
      .subscribe(online => this.online = online);
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @elemental-concept/offline-monitor

Weekly Downloads

1

Version

0.8.2

License

BSD-2-Clause

Unpacked Size

22.3 kB

Total Files

17

Last publish

Collaborators

  • ecdavid
  • aux
  • simke2090