OLD | NEW |
1 function handle_message(e) { | 1 function handle_message(e) { |
2 fetch(e.data.url) | 2 fetch(e.data.url) |
3 .then(response => response.text()) | 3 .then(response => response.text()) |
4 .then(text => e.ports[0].postMessage('Success: ' + text)) | 4 .then(text => e.ports[0].postMessage('Success: ' + text)) |
5 .catch(error => e.ports[0].postMessage('Error: ' + error)); | 5 .catch(error => e.ports[0].postMessage('Error: ' + error)); |
6 } | 6 } |
7 | 7 |
8 self.onmessage = handle_message; | 8 self.onmessage = handle_message; |
9 self.onconnect = e => { | 9 self.onconnect = e => { |
10 e.ports[0].onmessage = handle_message; | 10 e.ports[0].onmessage = handle_message; |
11 }; | 11 }; |
OLD | NEW |