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

Could accept custom storage #15

Open
lucasconstantino opened this issue Apr 7, 2019 · 1 comment
Open

Could accept custom storage #15

lucasconstantino opened this issue Apr 7, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@lucasconstantino
Copy link

It would be damn cool if this library accepted as config a custom storage, compliant to the Storage spec. This would not only cover session storage usage, but also any other possibility of storage.

@iamsolankiamit iamsolankiamit added the enhancement New feature or request label Jun 17, 2019
@mayteio
Copy link
Contributor

mayteio commented Jan 28, 2020

Hey @lucasconstantino do you have an example of other Storage interfaces you'd like to use?

Initial thoughts on API might include a provider (not the best) or a third argument to the hook.

// either
<StorageProvider store={window.sessionStorage || window.localStorage || window.IndexedDB.open()}>
  ...
</StorageProvider>

// or
useStorage('key', initialValue, window.sessionStorage || window.localStorage || window.IndexedDB.open())

In the latter case, it is almost worth creating a separate hook as software should do one thing and one thing well. Also see

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

No branches or pull requests

3 participants