| OLD | NEW |
| 1 self.onmessage = function(e) { | 1 self.onmessage = function(e) { |
| 2 var port = e.data.port; | 2 var port = e.data.port; |
| 3 var message = []; | 3 var message = []; |
| 4 | 4 |
| 5 Promise.resolve() | 5 var promise = Promise.resolve() |
| 6 .then(function() { | 6 .then(function() { |
| 7 // 1st matchAll() | 7 // 1st matchAll() |
| 8 return self.clients.matchAll().then(function(clients) { | 8 return self.clients.matchAll().then(function(clients) { |
| 9 clients.forEach(function(client) { | 9 clients.forEach(function(client) { |
| 10 message.push(client.id); | 10 message.push(client.id); |
| 11 }); | 11 }); |
| 12 }); | 12 }); |
| 13 }) | 13 }) |
| 14 .then(function() { | 14 .then(function() { |
| 15 // 2nd matchAll() | 15 // 2nd matchAll() |
| 16 return self.clients.matchAll().then(function(clients) { | 16 return self.clients.matchAll().then(function(clients) { |
| 17 clients.forEach(function(client) { | 17 clients.forEach(function(client) { |
| 18 message.push(client.id); | 18 message.push(client.id); |
| 19 }); | 19 }); |
| 20 }); | 20 }); |
| 21 }) | 21 }) |
| 22 .then(function() { | 22 .then(function() { |
| 23 // Send an array containing ids of clients from 1st and 2nd matchAll() | 23 // Send an array containing ids of clients from 1st and 2nd matchAll() |
| 24 port.postMessage(message); | 24 port.postMessage(message); |
| 25 }); | 25 }); |
| 26 e.waitUntil(promise); |
| 26 }; | 27 }; |
| OLD | NEW |