Re: [ServiceWorker] Add name param to Clients.openWindow() method (#711)

The `window.name` method:

1. Push message into SW
2. SW opens window with name 'chat-with-steve'
3. SW adds 'chat-with-steve' to IDB data store 'chat-window-names'
4. User clicks 'close all chat windows' in window
5. Window gathers window names from IDB 'chat-window-names'
6. For each, calls `window.open`, then calls `.close` on the handler
7. Window empties 'chat-window-names' IDB store

In this model you must keep the IDB store up to date, else `window.open` is going to open a new window.

The `windowClient.close()` method:

1. Push message into SW
2. SW opens window
3. SW adds new `client.id` to IDB data store 'chat-window-ids'
4. User clicks 'close all chat windows' in window
5. Window sends `postMessage` to SW, asking it to close all chat windows
6. SW gathers client IDs from IDB 'chat-window-ids'
7. SW gathers clients
8. For each client, calls `.close` if ID is in 'chat-window-ids'
9. SW empties 'chat-window-ids' IDB store

So doing it via the SW is a few more steps, but won't result in windows opening up. Also, by using IDs, the SW can "GC" the list in 'chat-window-ids' easily.

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

Received on Thursday, 2 July 2015 12:04:17 UTC