-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow override of cache storage provider #74
Comments
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.
@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
The text was updated successfully, but these errors were encountered: