-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker.js
More file actions
29 lines (27 loc) · 713 Bytes
/
worker.js
File metadata and controls
29 lines (27 loc) · 713 Bytes
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
28
29
let timeout = 10 * 1000;
function iter(limit, num) {
num = num || 0;
if (num >= limit) {
console.log("IM DONE");
return
}
console.log("not done yet")
const clients = self.clients.matchAll().then(clients => {
clients.forEach(client => {
let vibration = 100 * num;
client.postMessage({
body: 'hihi ' + vibration,
vibration: [5000, 100, 5000],
});
});
});
let next = num += 1;
self.setTimeout(function() {
iter(limit, next);
}, timeout)
}
onmessage = function(e) {
let dat = e.data;
console.log('got data ' + dat);
self.setTimeout(function() { iter(e.data); });
}