wxt-dev/wxt

[FEAT] support watch meta change in storage

Open

#1,988 建立於 2025年12月8日

在 GitHub 查看
 (1 留言) (0 反應) (0 負責人)TypeScript (511 fork)user submission
contribution welcomegood first issue

倉庫指標

Star
 (9,861 star)
PR 合併指標
 (平均合併 11天 22小時) (30 天內合併 51 個 PR)

描述

Feature Request

Now we only support to watch the value of the local storage. But can't watch the change of the metadata of local storage variable.

What are the alternatives?

Now we have to add $ at the end of the KEY local:someKey$ to watch its metadata. But in the future, the underline implementation of the meta may change, and may should not add $.

This is the work around of my code

  // Add $ to the key to get the meta key for LAST_SYNCED_CONFIG_STORAGE_KEY
  const metaKey = `local:${LAST_SYNCED_CONFIG_STORAGE_KEY}$`

  const unwatch = storage.watch<LastSyncedConfigMeta>(metaKey, (_, newMeta) => {
    const meta = newMeta
    setAtom(meta?.lastSyncedAt ?? null)
  })

Additional context

Add any other context or screenshots about the feature request here.

貢獻者指南