svelte-webext-storage-adapter
svelte-webext-storage-adapter copied to clipboard
Feedback wanted: Using custom stores
This package creates Svelte writable stores for you, and offers no alternatives. Is there any demand for a way to specify a different compatible implementation of the store contract to use? How would you use this feature if I provided it?
I'm thinking the API for this would be a new storeFactory option for webextStorageAdapter(). The value would be a function that takes the initial value as an argument and returns the store object.
Hi, I'm using this and have come across a need for a custom store. My specific use is pretty simple and only really needs the ability to pass a custom set. parameter to writable, but currently I had planned on adding another property/method to the custom store, but not 100% needed.
If you had an idea in mind on how you wanted to implement it I could take a shot at it in a PR.
edit: was half awake when I initially commented, edited for clarity.
This could be much more reasonably implemented in v3, as currently there's a lot of manipulation of the store object to collect data to write to storage, whereas v3 will accomplish the same with just a call to .subscribe(). However, the current v3 plans include removing the options parameter for API simplicity. If you're sure that custom stores would make your work a lot easier, I could put options back in the plans so that there's a place for a storeFactory option.
The v3 beta has been released (see #14); I decided against removing options but have not yet added a store factory option. @fielding, I'd appreciate more info on how helpful this would be to you. You mentioned you wanted to pass a custom set paramater to writable (I assume you mean start parameter?), but now that v3 uses subscriptions internally, a writable would always be "started", so I doubt it would help you much now.
v3 was released without this, but I'm open to discussing it for a 3.x release.