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

How to invalidate storage after some time (expiration feature)? #21

Open
gremo opened this issue Sep 27, 2020 · 0 comments
Open

How to invalidate storage after some time (expiration feature)? #21

gremo opened this issue Sep 27, 2020 · 0 comments

Comments

@gremo
Copy link

gremo commented Sep 27, 2020

Hi, first thanks for this great library!

I'm using this library to store a cart-like state inside my CartComponent:

const [cart, dispatch] = useStorageReducer(localStorage, 'cart', cartReducer, {
  createdAt: Math.floor(Date.now() / 1000),
  items: []
});

I'm wondering, how to invalidate the storage after 1 hour, for example? In other words, useStorageReducer should return { items: [] } after 1 hour, re-setting the state eventually stored in the localStorage object.

Is this possible? Thanks!

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

1 participant