joshnuss / svelte-persisted-store

A Svelte store that persists to localStorage
MIT License
994 stars 41 forks source link

A bust cache method #263

Closed intercepted16 closed 3 months ago

intercepted16 commented 3 months ago

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.

joshnuss commented 3 months ago

Hi @intercepted16!

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

Open to PRs

intercepted16 commented 3 months ago

@joshnuss I have created a PR #265