You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Doing this, I run into issues where this is not defined when subscribing. If I pull the subscribe and update methods off of chromeStorageLocal, I run into similar issues when calling update from my setters (i.e. update(...) instead of settings.update(...)).
I was going to try extending the ChromeStorageStoreAdapter class, but it is not exported.
Likely this approach just is not compatible with the library. And assuming it isn't and isn't meant to be, I'm wondering if you have any other guidance on a way to type the store with an object and allow callers to set individual keys without having to pass back in the entire object themselves.
I'm trying to avoid doing the following from the callers:
I'm tried a different approach and am very happy with the results. Instead of trying to manage one object I decided to use a separated key for each property. It looks like the following:
classSettingsStorageLocal{constructor(){this.recording=chromeStorageLocal("recording")this.recordTabId=chromeStorageLocal("recordTabId")this.onSettingsPage=chromeStorageLocal("onSettingsPage")this.settingsUrl=chromeStorageLocal("settingsUrl")}// We could also make the Readable and the define settersrecording: Writable<boolean>recordTabId: Writable<string>onSettingsPage: Writable<boolean>settingsUrl: Writable<string>init(): void{this.recording.set(false)this.recordTabId.set("")this.onSettingsPage.set(false)this.settingsUrl.set(`chrome://extensions/?id=${chrome.runtime.id}#allow-incognito`)}}conststore=newSettingsStorageLocal()exportdefaultstoreexportconst{recording, recordTabId, onSettingsPage, settingsUrl}=store
I'm happy to discuss the previous issues I was having but am going to go ahead and close this.
This library appeared to be exactly what I was looking for (and trying to implement myself), but as I tried to use it I ran into issues.
My goal is to keep my store strongly typed and provide setters for each field that should be editable. Something like the following:
Doing this, I run into issues where
this
is not defined when subscribing. If I pull thesubscribe
andupdate
methods off ofchromeStorageLocal
, I run into similar issues when callingupdate
from my setters (i.e.update(...)
instead ofsettings.update(...)
).I was going to try extending the
ChromeStorageStoreAdapter
class, but it is not exported.Likely this approach just is not compatible with the library. And assuming it isn't and isn't meant to be, I'm wondering if you have any other guidance on a way to type the store with an object and allow callers to set individual keys without having to pass back in the entire object themselves.
I'm trying to avoid doing the following from the callers:
The text was updated successfully, but these errors were encountered: