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

need AsyncLocalStorage (was #904) #906

Jxck opened this Issue May 31, 2016 · 4 comments


None yet
4 participants
Copy link

Jxck commented May 31, 2016

localStorage is handy for much usecases, but unfortunately it's api based on Sync.
so in service worker we need to use Indexed DB for every kind of data, only if you need to store 1byte flag.

I think if we don't need index for large data search, and don't wanna preparing ceremony for storing data,
it's better to have a localStorage witch having Async API.

or other sight of view, Cache API is much handy than IDB, but it's specialised for Request/Response.
AsyncLocalStorage will looks something like CacheAPI witch is generalised for generic javascript object.
(we may say it as parent class of Cache API class)

this will solve may use case I think, for example..

  • every use case for localStorage at window context
  • saving request data for sync event (I described it at #904)
  • saving simple/single/small data like flag, counter etc
  • case for preparing scheme at install/activate are over kill

will seems..

localStorage with AsyncAPI (returning promise)

asyncStorage.setItem('key', 'value').then();
asyncStorage.getItem('key').then(console.log.bind(console)); // 'value'
// etc

generalised cache api'v-1').then((store) => {
  store.put('key', {data:'value'}).then();
  store.match('key').then(console.log.bind(cosnole)); // { data: 'value' }
  // etc but, no add/addAll

This comment has been minimized.

Copy link

delapuente commented Jun 6, 2016

@Jxck despite the proposal for adding an async API to localStorage is good and IDB API sucks, you can use localForage.


This comment has been minimized.

Copy link

jakearchibald commented Jun 6, 2016

This isn't the right repo for this, but it might be worth proposing at the WICG.

In the mean time, little libs like make IDB a lot easier. Includes async localstorage example.


This comment has been minimized.

Copy link

domenic commented Apr 11, 2018

FWIW, I've got a proposal for this that I think is pretty complete: Feel free to file issues on the tracker there, or chime in on existing discussions!


This comment has been minimized.

Copy link

Jxck commented Apr 12, 2018

@domenic 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment