Single watcher for multiple keys
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10.5k
- Forks
- 564
- PR merge metrics
- No merged PRs in 30d
Description
Feature Request
This snippet allows for watching a single item:
https://github.com/wxt-dev/wxt/blob/c0aa12089e24c9f0cb01fb3f8546f17096b21341/packages/wxt/src/storage.ts#L434-L447
I also wish to have a watcher setup like this:
const unwatch = storage.watch({
"local:item1"((newValue, oldValue) => {...}),
"local:item2"((newValue, oldValue) => {...})
});
unwatch();
Is your feature request related to a bug?
N/A
What are the alternatives?
storage.watch("local:item1", (newValue, oldValue) => {...});
storage.watch("local:item2", (newValue, oldValue) => {...});
Additional context
This functionality is available in Plasmo
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/wxt/src/storage.ts at lines 434-447, where the existing single-item watcher is implemented. Trace its callback and cleanup behavior, then determine how the proposed map of keys to callbacks should preserve those semantics. Done means one watcher can register both local:item1 and local:item2 callbacks and the returned unwatch function removes them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100