-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
1. to developAccepted and waiting to be taken care ofAccepted and waiting to be taken care ofenhancementNew feature or requestNew feature or request
Description
Problem
There is no clean way to listen for a specific BrowserStorage instance storage event
Proposal 1: make scopeKey public
nextcloud-browser-storage/lib/scopedstorage.ts
Lines 19 to 21 in 8379a79
| private scopeKey(key: string) { | |
| return `${this.scope}${key}` | |
| } |
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`
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
1. to developAccepted and waiting to be taken care ofAccepted and waiting to be taken care ofenhancementNew feature or requestNew feature or request