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