Skip to content

Proposal: StorageArea.onChanged filters #475

@polywock

Description

@polywock

Problem

When monitoring storage changes via a service worker, all changes activate the worker, even if only a specific value matters.

Proposal

Allow StorageArea.onChanged.addListener to accept an optional StorageChangeFilter as an argument.

browser.storage.local.onChanged.addListener(callback, filter?: StorageChangeFilter)

// Usage example 
browser.storage.local.onChanged.addListener(handleChanges, {startsWith: ['flags:', 'global:']})

interface StorageChangeFilter {
    // positive parameters 
    startsWith?: string[], 
    contains?: string[], 
    equals?: string[], 
    
    // negative parameters
    doesNotStartWith?: string[], 
    doesNotContain?: string[], 
    doesNotEqual?: string[]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    follow-up: chromeNeeds a response from a Chrome representativeproposalProposal for a change or new featuresupportive: firefoxSupportive from Firefoxsupportive: safariSupportive from Safaritopic: storageIssues related to persisting data. Topics include browser.storage, web storage, and new APIs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions