nextcloud-libraries / nextcloud-libraries/nextcloud-browser-storage
[Feature Request] Provide a way to listen `storage` event
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5
- Forks
- 0
- Avg merge
- 5m
- Merged PRs (30d)
- 12
Description
Problem
There is no clean way to listen for a specific BrowserStorage instance storage event
Proposal 1: make scopeKey public
Providing it as a public property allows filtering the storage events manually to handle only a specific browserStorage instance.
Proposal 2: provide a method to subscribe for the storage event
Option 1: add onStorage method
class ScopedStorage implements NextcloudStorage {
onStorage(key: string, callback) {
onStorage(callback) {
const callbackWithFilter = () => {...}
window.addEventListener('storage', callbackWithFilter)
return () => window.removeEventListener('storage', callbackWithFilter)
}
offStorage(callback) {
// callback should be stored in a Map
}
}
Option 2: provide additional functions
declare function onBrowserStorageChange(browserStorage: ScopedStorage, key?: string, callback)
declare function onBrowserStorageChange(browserStorage: ScopedStorage, callback)
Option 3: extend EventTarget
class ScopedStorage implements NextcloudStorage extends EventTarget {
// Override `addEventListener` and `removeEventListener`
}
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 with lib/scopedstorage.ts, especially the scopeKey definition referenced in the issue, and inspect how ScopedStorage relates to the browser storage event. Compare the proposed public property, subscription methods, and EventTarget approaches, then determine which API the project should adopt and how callers would unsubscribe or filter by key. Done means a decided, documented way to listen for changes from one ScopedStorage instance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100