An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

[![npm version](https://badge.fury.io/js/%40novyk%2Fing.svg)](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