Closed muuvmuuv closed 2 years ago
Oh.. yes my bad. I was aware of that the time I installed cashew a while back and just forgot to look at it again. Sorry!
Unfortunately, I am stuck with overriding the http cache class provider. None of the internal classes are exported so my TypeScript compiler is reporting errors when importing them.
./src/app/core/http/http.module.ts:3:0-68 - Error: Module not found: Error: Package path ./lib/cache-storage is not exported from package @ngneat/cashew
@Injectable()
export class HttpCache /* implements HttpCacheLocalStorage */ {
async has(key: string) {
return !!(await Storage.get({ key: createKey(key) }))
}
async get(key: string) {
return await Storage.get({ key: createKey(key) })
}
async set(key: string, response: HttpResponse<unknown>) {
await Storage.set({
key: createKey(key),
value: JSON.stringify(response),
})
}
async delete(key: string) {
await Storage.remove({ key: createKey(key) })
}
clear() {
// WIP
}
}
import { HttpCacheStorage } from '@ngneat/cashew/lib/cache-storage'
// module provider...
useHttpCacheLocalStorage,
{
provide: HttpCacheStorage,
useClass: HttpCache,
},
Can you open a PR and export it, please?
Working on it but don't have much free time ATM because I am still moving out. I am still testing the async stuff because my Provider is async.
I'm submitting a...
Current behavior
I am not able to change the storage provider from localStorage to something else
Expected behavior
A exposed HttpCacheStorage provider to modify it. We for example use CapacitorStorage.
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Environment