Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vadimdez/ngx-online-status
🔛 Angular 5+ Detect online/offline state
https://github.com/vadimdez/ngx-online-status
angular offline online state
Last synced: 3 months ago
JSON representation
🔛 Angular 5+ Detect online/offline state
- Host: GitHub
- URL: https://github.com/vadimdez/ngx-online-status
- Owner: VadimDez
- License: mit
- Created: 2017-11-01T09:40:23.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-24T02:07:29.000Z (over 1 year ago)
- Last Synced: 2024-10-14T23:21:34.573Z (3 months ago)
- Topics: angular, offline, online, state
- Language: TypeScript
- Homepage: https://vadimdez.github.io/ngx-online-status/
- Size: 3.89 MB
- Stars: 22
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# ngx-online-status
![Downloads](https://img.shields.io/npm/dm/ngx-online-status.svg?style=flat)
[![Build Status](https://travis-ci.org/VadimDez/ngx-online-status.svg?branch=master)](https://travis-ci.org/VadimDez/ngx-online-status) ![https://www.paypal.me/vadimdez](https://img.shields.io/badge/paypal-donate-yellow.svg)> Detect online/offline state
Angular 5+ Module to track online and offline state
### Demo
[https://vadimdez.github.io/ngx-online-status/](https://vadimdez.github.io/ngx-online-status/)
or stackblitz code/demo
[https://stackblitz.com/edit/ngx-online-status](https://stackblitz.com/edit/ngx-online-status)
## Install
```
npm install ngx-online-status --save
```## Usage
1. Import `OnlineStatusModule` to your module
```typescript
import { OnlineStatusModule } from 'ngx-online-status';@NgModule({
declarations: [
// ...
],
imports: [
OnlineStatusModule
],
providers: [
//...
]
})
```2. Inject `OnlineStatusService` and use it:
```typescript
import { OnlineStatusService, OnlineStatusType } from "ngx-online-status";export class AppComponent {
status: OnlineStatusType = this.onlineStatusService.getStatus(); // get initial statusconstructor(private onlineStatusService: OnlineStatusService) {
this.onlineStatusService.status.subscribe((status: OnlineStatusType) => {
// use status
this.status = status;
});
}
}
```##### OnlineStatusType
`OnlineStatusType.OFFLINE` equals to `0`
`OnlineStatusType.ONLINE` equals to `1`
## License
[MIT](https://tldrlegal.com/license/mit-license) © [Vadym Yatsyuk](https://github.com/vadimdez)