RxJS async pipes for Angular
To get started, install the package from npm. The latest version supports Angular 7 and above.
You can use either npm or yarn to install @fivethree/async-pipes
from npm.
npm install @fivethree/async-pipes --save
# or if you are using yarn
yarn add @fivethree/async-pipes
Import the pipe module you like to use into your page or components module:
import { NgModule } from '@angular/core';
import { PendingPipeModule } from '@fivethree/async-pipes';
@NgModule({
imports: [
PendingPipeModule
]
})
export class HomePageModule {}
<div *ngIf="numbers$ | empty | async">
Empty State - Source Observable emitted an empty array
</div>
<div *ngIf="numbers$ | error | async as error">
{{error}}
</div>
<div *ngIf="numbers$ | pending | async">
Pending State - Source Observable has not emitted yet
</div>