Re: [ServiceWorker] Add cookie accessor/setter methods? (#707)

> Is there any benefit in:

Do you mean that we can't make values writable because setting them should be asynchronous? If so, then yes, all of them are readonly.

> Interesting. If we're going to remove name from `Cookie` it may be better to remove `getAll` and go with `cookies.keys()` which returns an array of cookie names, which you can get with `.get` if you need to.

I like the idea, although removing `name` is not necessary since it's immutable in the design above anyway.

The only downside of this is that if someone really needs to get all the cookies, he needs to use more complex and slower construction like
```javascript
function cookieEntries() {
  return navigator.cookies.keys().then(
    keys => Promise.all(keys.map(
      key => navigator.cookies.get(key).then(value => [key, value])
    ))
  );
}
```

So I'd propose to add both `keys()` and `entries()` / `getAll()`.

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/707#issuecomment-110328779

Received on Tuesday, 9 June 2015 11:46:08 UTC