@aviellv/angular-async-directive
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.0 • Public • Published

    angular-async-directive

    npm version Build Status

    An angular (6+) directive for handling asynchronous requests (observables) in a fluent way

    Motivation

    A common use case for consuming async streams is displaying a loading animation, the data itself on success or a failure message when it errors. This directive is meant to ease this process and allow a quick way to handle all three states (loading,success,failure).

    Example usage

     
        this.httpQuery$ = this.http.get<string>("./api/text");
        
     
        <ng-container [ngAwait]="httpQuery$">
          <ng-container *ngAwaitLoading>loading..</ng-container>   
          <ng-container *ngAwaitSuccess="let data"> data result: {{ data }}</ng-container> 
          <ng-container *ngAwaitFailure="let error"> error has occured: {{ error.message }}</ng-container>
        </ng-container>
     

    Install

    npm i @aviellv/angular-async-directive

    DownloadsWeekly Downloads

    7

    Version

    1.0.0

    License

    Apache-2.0

    Unpacked Size

    11.7 kB

    Total Files

    6

    Last publish

    Collaborators

    • aviellv