ngneat / cashew

🐿 A flexible and straightforward library that caches HTTP requests in Angular
https://www.netbasal.com
MIT License
682 stars 33 forks source link

feat: allow passing existing `HttpContext` to `withCache` function #43

Closed FabienDehopre closed 3 years ago

FabienDehopre commented 3 years ago

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

When you use the withCache() function in a HttpClient method, it needs to be assigned to the context option. How do you add something else to the HttpRequest context ?

Issue Number: #42

What is the new behavior?

Add a second argument to withCache function to pass an optional existing HttpContext returned from another function (similar to withCache). If the existing HttpContext has been provided, the function will use it; otherwise, the function will create a new HttpContext.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

FabienDehopre commented 3 years ago

I've already updated the code by moving the second argument to the option object (and removing it). However, I still have to update the documentation (README.md). I'll do it ASAP tomorrow.

FabienDehopre commented 3 years ago

@NetanelBasal I've updated the readme can you have a look and tell me if it's ok or not ?