Could not find the option to clear cache or "render" the client again
johnico opened this issue · 2 comments
Hello
1 . i have to get a new api key by user action
once I update the config object , the ais-instasearch keep working with the previous api key
so i m trying to find a way to clear cache or update the config object , in order to "render again" the instance search without rendering all the component
fetchKey(someData: string[]) {
const data: Algolia.SearchApiKeyOnCallData = { someId, someData };
.......
getAlgoliaApi(data)
.toPromise()
.then((apiKey: string) => {
const searchClient = algoliasearch('id', apiKey);
this.config = {
indexName: `index`,
searchClient,
};
})
.catch((e) => {
});
html :
<ng-container *ngIf="config">
<ais-instantsearch [config]="config">
</ais-instantsearch>
</ng-container>
2- is it possible to always query algolia without using cache request while search or using facets ? (without refresh button or smth like that)
tried searchClient.clearCache()
(does not work)
Could it be that you're searching for Refresh?
angular-instantsearch/examples/storybook/src/custom-widgets.ts
Lines 106 to 136 in 1a12f5e
Also the cache can be disabled completely by passing:
// v3 algoliasearch
const searchClient = algoliasearch('id', 'key', { cache: false });
// v4 algoliasearch
import { createNullCache } from '@algolia/cache-common';
const searchClient = algoliasearch('id', 'key', {
{
// Caches responses from Algolia
responsesCache: createNullCache()
// Caches Promises with the same request payload
requestsCache: createNullCache()
},
});
@Haroenv about cache this is good. thanks
the issue is that if i replace the apiKey because i got a new client the instasne seatch still has the same client
i print the apiKey and it is the same always until i will refresh or re render the page
i figured it out only by render all component again so it will generate the html (with ng-if) from scratch but this is a bad solution for me because i got "refresh" and lost my search params
so i have the function fetchKey() that update the "this.config" with the searchClient , but its does not help
the instance still with the first one
i thunk might be the search client is part of config object and the angular did not recognize it a change?
so at the end my goal is to replace the search client without refresh the page
- also after updated the searchClient , how can I call to the query to update the state ? kind of refresh but not from a button .
so to focus the question:
i got action from user to update list
based on this list i generate a new searchClient
now i need to update the ui +refresh the queries on the ui because now i have a different data