@lonli-lokli/ng-result
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

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

Package Sidebar

Install

npm i @lonli-lokli/ng-result

Weekly Downloads

0

Version

1.3.0

License

MIT

Unpacked Size

379 kB

Total Files

50

Last publish

Collaborators

  • lonli-lokli