Re: [ServiceWorker] Is a new property to get the navigation's target client needed? (#817)

> Clients can disappear at any time.

Right, but `clients.get(fetchEvent.clientId)` currently returns null when the client no longer exists. This means I can remove any book-keeping data in idb relating to that client.

The change you're suggesting means `clients.get(fetchEvent.clientId)` returns null when the client no longer exists, may never exist, or may exist at some point in the future, or may point to a client we can't expose (another origin). This makes it useless for the book-keeping case.

That aside, I don't think it's useful to reuse `fetchEvent.clientId` for two separate things, especially as we might want to expose both of those things separately in future. It could be useful to know the id of the client that initiated the request, and the one potentially created as a result of the response. You could use this to link clients together and build a navigation tree.

For the promises case, `clients.get(id)` could wait if it's passed a reserved id, and only resolve once the client is created, or the browser knows the client will not be created.

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

Received on Friday, 19 February 2016 09:43:34 UTC