ngx-caching
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

ngx-utils

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

Readme

Keywords

none

Package Sidebar

Install

npm i ngx-caching

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

50.5 kB

Total Files

16

Last publish

Collaborators

  • gabriel.rusu.dev