https://github.com/navix/ing
🦥 Simple async state container for RxJS and Angular.
https://github.com/navix/ing
angular rxjs
Last synced: about 1 month ago
JSON representation
🦥 Simple async state container for RxJS and Angular.
- Host: GitHub
- URL: https://github.com/navix/ing
- Owner: navix
- Created: 2021-12-23T15:49:23.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-07T18:51:47.000Z (about 4 years ago)
- Last Synced: 2024-04-23T20:18:54.443Z (about 2 years ago)
- Topics: angular, rxjs
- Language: TypeScript
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://www.npmjs.com/@novyk/ing)
# 🦥 Ing
Simple async state container for RxJS and Angular.
## Features
* Stores multiple async operation states: New, Ongoing, Succeed, Failed.
* Gives Observables with the state.
* Has a helper operator for RxJS integration.
* Adapted for using in Angular templates.
* Easily integrates with your custom services and components.
* Has no additional dependencies and complex abstractions.
## Installation
```
$ npm i @novyk/ing
```
## Usage
#### Create instance of container
```
import { ing, Ing } from '@novyk/ing';
...
component MyCompontent {
loading = new Ing();
...
}
```
#### Handle state when making requests
```
import { ing, Ing } from '@novyk/ing';
...
component MyCompontent {
...
loadData() {
this.loading.start();
this.dataService
.load()
.pipe(
ing(this.loading),
)
...
}
}
```
#### Use container in templates
```
Data is loading...
...
```
Or subscribe to streams:
```
Data is loading...
...
```
Using `ngSwitch`:
```
Data is loading...
...
Data loading failed!
```
## Licence
MIT