JSPM

@lonli-lokli/ng-result

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q32037F
  • License MIT

Angular Library with set of components/directives/pipes for easier work with Result union from https://github.com/Lonli-Lokli/ts-result

Package Exports

  • @lonli-lokli/ng-result
  • @lonli-lokli/ng-result/bundles/lonli-lokli-ng-result.umd.js
  • @lonli-lokli/ng-result/fesm2015/lonli-lokli-ng-result.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@lonli-lokli/ng-result) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Ng-Result is an Angular Library with set of components/directives/pipes for easier work with data, using Ts-Result

GitHub release (latest by date) GitHub commit activity GitHub license NPM

Demo

About

Result is an union of following types: Initial, Pending, Failure and Success.

The problem it solving present is a very common one. You are loading a list of things but instead of showing a loading indicator you just see zero items. Same happens with actual data loading - sometimes you just do not think it will fail.

In my mental model, REST requests have one of four states:

  • We haven't asked yet.
  • We've asked, but we haven't got a response yet.
  • We got a response, but it was an error.
  • We got a response, and it was the data we wanted.

That is the purpose of this library - allow clean usage over this states with Angular.

Installation

ng add @lonli-lokli/ng-result

Usage of components

<ll-result [data]="data$ | async">
  <ng-container *ifSuccess="data$ | async; let ok">
    Here is the type-safe response: {{ok}}
  </ng-container>
</ll-result>

Components

TODO

Publish

Run npm run publish