0.8.2 • Published 3 years ago

@elemental-concept/offline-monitor v0.8.2

Weekly downloads
27
License
BSD-2-Clause
Repository
github
Last release
3 years ago

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);
  }
}
0.8.2

3 years ago

0.2.0

4 years ago

0.1.0

5 years ago

0.0.1

5 years ago