Closed FabienDehopre closed 3 years ago
withCache() returns the context - use it.
Indeed, it would work if you add new context value after having called withCache()
but what if you have other function that also returns a HttpContext
?
For instance, we have a library where I'm working that exposes 2 other functions that each returns a HttpContext
so to make then "chainable", they both accept a previous HttpContext
to reuse it or create a new HttpContext
when none is given.
Example:
export function withLoadingSpinner(context: string, previousContext?: HttpContext): HttpContext {
return (previousContext ?? new HttpContext()).set(LOADING_SPINNER_CONTEXT, context);
}
What about adding something like that to the withCache()
function either as a new option value or as an additional parameter?
You're welcome to create a PR
I'm submitting a...
Current behavior
When you use the
withCache()
function in aHttpClient
method, it needs to be assigned to thecontext
option. How do you add something else to theHttpRequest
context ?