@ngxgs/connection-status
v0.0.6
Published
Provides a simple way to verify when user is online or offline, and listen to these events.
Maintainers
Readme
Connection Status
This library provides a very simple way to listen the events of online and offline. This library is platform-agnostic, that means it's works in Server-Side Rendering (SSR) applications and Web-Wokers.
Getting Started
Install
Run the command: npm install @ngxgs/connection-status, inside your application.
Usage Exemple
import { Component, inject } from '@angular/core';
import { ConnectionStatus } from '@ngxgs/connection-status';
@Component({
...
})
export class MyComponent {
connService = inject(ConnectionStatus);
constructor() {
this.connService.onStatusChange$.subscribe((event) => {
// verify if the user go online
if (event.type === 'online') {
// do something...
}
// verify if the user go offline
if (event.type === 'offline') {
// do something else...
}
});
}
}Contact
Repository
You can contribute to this library through its GitHub repository: ngxgs/libraries.
