joshnuss/svelte-persisted-store

A bust cache method

intercepted16 opened this issue · 2 comments

It would be beneficial to introduce a reset (or cache busting) feature to the Svelte store. This feature would provide a 'bust' method on the store that, when invoked, effectively reevaluates the initial store value provided. This is particularly useful when the initial store value is an awaited Promise, a function call, or similar dynamic content, but not for static values like arrays or objects.

Currently, I am using a workaround involving an additional store that holds a boolean value. This store is subscribed to, and when its value is set to true, the main store value is "reset." However, this approach is neither as clean nor as efficient as having a dedicated 'bust' method.

Hi @intercepted16!

Yes, I agree, there should be a reset() function.

Open to PRs

@joshnuss I have created a PR #265