[w3c/ServiceWorker] Provide a way to attach data to clients (#1475)

Originally raised while discussing whether we should have `client.isFrozen` etc.

There's a lot of state data we could attach to clients, but developers also `postMessage` clients to 'ask' for some app-specific data, like "is the user currently typing a message?".

We could improve both situations by allowing developers to attach clonable data to a client.

Rough design that I haven't put much thought into:

```js
// From a page (or other client):
await clients.setClientData({ foo: 'bar' });
```

```js
// In a service worker:
const client = (await clients.matchAll())[0];
console.log(client.data?.foo); // 'bar' or undefined.
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1475

Received on Friday, 4 October 2019 10:44:08 UTC