Is there a way to watch storage changes for all keys, or keys matching a prefix?
I want to get updates on all changes to storage, or all changes to keys matching "example_*"
2 Replies
Yep. This is a snippet I use to observe and log all changes to local storage. You can just update the
areaName
filter to your needs.
I put that in a message handler or port then look at the dev tools for the service worker.
If you want to get access to that in a CSUI component I believe it would be a similar callback.
In my CSUI component I have a singleton setup like this.
which I then import across different components. Honestly not sure if its needed, it's just kind of part of the code now.
Either way in my CSUI component I then create a useEffect
hook like this
Not sure if there is a generic watch all that you can use there. Might have access to the chrome.storage
API there too.
The 2nd method won't work for your wild card scenario unfortunetly.ok--I was hoping to avoid reference chrome.storage but looks like Plasmo storage only lets you watch specific keys, not the whole thing