Closed leocharrua closed 5 years ago
Hello @leocharrua, you can use @CacheBuster as specified in the docs. Let me know if I can help further.
Hi. Sorry, I don't understand how I must use that decorator. Can you give me a example code? Thanks
Sorry, can you help me? I put the @cachebuster in the function ... then? How I clear the cache (allow to call the http.post)? Thanks again.
You can decorate your post method (the method which will save some data to the server and i.e - need to clear the cache).
You need to provide a subject to it which will be next'ed
when your save request completes.
Then you also provide the very same subject to the Cacheable
decorator on your data-fetching method, so it knows when to clear its cache.
In short, when you call saveData
and it completes, all cache of getData
will be cleared.
If you want more control on when to clear the getData
cache, you can just call saveDataSubject.next()
on your own. You can even export the subject and use it anywhere else.
const saveDataSubject = new Subject();
@CacheBuster(
{
cacheBusterNotifier: saveDataSubject
}
)
saveData(){}
@Cacheable(
{
cacheBusterObserver: saveDataSubject.asObservable()
}
)
getData(){}
Thank you very much!!!
Hello.
Thanks for his work.
How do you clear (refresh) the cache programmatic?
Thanks