wxt-dev / wxt-dev/wxt

Single watcher for multiple keys

Open
#999 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

contribution welcome good first issue
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.