Skip to content

Angular(TypeScript) library that contains reusable services like CacheService for browser caching either in session or local storage and a HttpCacheClient (a HttpClient wrapper that caches the results for speed improvements)

License

Notifications You must be signed in to change notification settings

gabriel-rusu/ngx-utils

Repository files navigation

Project logo

ngx-utils

License

Angular library that enables developer accessible browser caching by providing a CacheService and a HttpCacheService.

📝 Table of Contents

🧐 About

This Angular library provides two services:

  • CacheService: which interacts directly with the browser local/session storage
  • HttpCacheService: which is a wrapper(decorator) around Angular HttpClient that offers the ability to cache any request that you want to (including post request) and offers the results as a Observable of the desired type, exactly as HttpClient.

🏁 Getting Started

To use this library you should have at least Angular 13. Installation of this library can be done using the following commands, depending on your package manager.

  • npm: npm i ngx-caching
  • yarn yarn add ngx-caching

🎈 Usage

The following is a basic usage example of the HttpCacheService:

...
import {HttpCacheService} from "ngx-caching";
...

constructor(private configService: ConfigService, private httpCached: HttpCacheService) { }

getValuesByType(typeId: number):Observable<any> {
 return this.httpCached.get(this.configService.getPath('dictionary', 'entries', {typeId}));
}

In the above example, the values that will be retrieved will also be cached, so any subsequent subscription to this method will result in a cache look-up rather than another HTTP request.

⛏️ Built Using

✍️ Authors

About

Angular(TypeScript) library that contains reusable services like CacheService for browser caching either in session or local storage and a HttpCacheClient (a HttpClient wrapper that caches the results for speed improvements)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published