@lonli-lokli/ng-result
v1.3.0
Published
Angular Library with set of components/directives/pipes for easier work with Result union from https://github.com/Lonli-Lokli/ts-result
Downloads
3
Maintainers
Readme
Ng-Result is an Angular Library with set of components/directives/pipes for easier work with data, using Ts-Result
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