Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Are browser native storage APIs supported? #96

Closed
Xerillio opened this issue Nov 28, 2021 · 2 comments
Closed

Question: Are browser native storage APIs supported? #96

Xerillio opened this issue Nov 28, 2021 · 2 comments

Comments

@Xerillio
Copy link

Xerillio commented Nov 28, 2021

I'm trying to use this library in a browser extension that I plan on developing for multiple browsers - in particular Chrome and Firefox. As the extension consists of both a popup menu, background page and content scripts it gets a little complicated trying to access the same localstorage data from all parts of the extension.

In the README store.area(name, customStorageObject) is mentioned as a way of "plugging in" a different storage provider/source as far as I understand. I tried getting it to work with Chromes storage API, but it seems the required API from this library is fairly different from Chrome's. With Chrome's own storage API it should be much easier to access the same data without intercommunication between scripts, which is what I'm looking for.

So my question is: is it at all possible to use this library with a browser's native storage API without having to write a custom wrapper to make it fit into store.area?

@Xerillio Xerillio changed the title Question: Question: Are browser native storage APIs supported? Nov 28, 2021
@nbubna
Copy link
Owner

nbubna commented Nov 28, 2021

If the API for the browser's native storage conforms to this interface:
https://developer.mozilla.org/en-US/docs/Web/API/Storage
then it should work fine. If it doesn't, then you'll need to write a wrapper to adapt the interface.
I've really never worked in extension-land, so that's all i could tell you. Is this the API you want to adapt store2's interface for?
https://developer.chrome.com/docs/extensions/reference/storage/
Because it appears that's an async API. I'm not sure how you'd adapt that for the synchronous API store2 provides.

@Xerillio
Copy link
Author

Yea, that's the one. Didn't think far enough to realize that, yea, that's probably not possible to adapt to store2.

Thanks for the feedback. I'll probably have do my own cross-browser solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants